-
Notifications
You must be signed in to change notification settings - Fork 756
Description
In #8048, the proposal is to use a new rule for opting-in to cross-document transitions.
This has a few drawbacks:
- You can't opt-out of the transition based on things in the document, e.g.
body.disable-transitions { @cross-document-transitions: allow; } - It's totally different from the way you disable of same-document transitions (
::view-transitions { display: none }) - Its limited to opting in/out, it requires extensions or JS to allow, for example, different names for cross-document transition.
- It's a bespoke rule, so we have to define how it interacts with other rules and so forth, and developers have to learn it.
Proposing, instead, to use a media-query:
@media (page-tranistion: incoming | outgoing | any | ...` (we can bikeshed this of course)To accomplish the original requirement of disabling cross-doc transitions by default, the default UA stylesheet can be:
@media (page-transition) {
::view-transition { display: none }
}This separates the condition (is this a page-transition?) with the action (the transition should be animated/skipped) and thus allows for more mixing and matching, e.g:
@media (page-transition) or (prefers-reduce-motion) {
::view-transition { display: none }
}
@media (page-transition: outgoing) {
body.disallow-outgoing-tranistions {
::view-transition { display: none }
}
}We can also change the transition names based on whether this is a page transition:
#my-element { view-transition-name: some-name }
@media (page-transition) {
#my-element { view-transition-name: some-other-name }
}We also get the JS API for free matchMedia and MediaQueryList/change event gives the developer all the JS observability they need. There's no need for a ViewTransition object.
Note that to enable this, we would have to clearly define in the lifecycle at which exact points in the navigation/rendering lifecycle the page-transition media is matched, and we would have to enable the ::view-transition pseudo-element when navigating to a page that can potentially trigger a page transition.