-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-view-transitions-2] Media query alternative to cross-document opt-in #8868
Comments
In general, I like this at-rule approach. A few remarks/questions:
|
Outgoing - I think it should be when a same-origin navigation fetch is initiated, but it can also be the last frame. Either would work, the first one is a bit easier to understand, and perhaps we can use it for other things, e.g. call it Incoming - when the page is render-unblocked or reactivated, but before presenting.
See below. unlike what I wrote in the OP, I am convinced that we should have a "hard" opt-in, probably in HTML, to avoid cases where someone accidentally enables cross-doc-VT with e.g. by putting
Thinking about this again, I think we should actually keep the The reason is that with only using default styles it's very easy to accidentally enable cross-document transition, as media-queries don't affect specificity. So I suggest to keep the opt-in, and make it very simple and binding. And use the media query for everything else:
It should be a double opt-in. Transitioning from blank is something that we should address separately, but in general view-transitions don't help you with that at all, and you can use regular
That was an attempt to think ahead, but I actually think we shouldn't do any of this at all. It leaks HTML/routing concerns into CSS. If a developer wants to achieve that kind of customization, they should put something in the DOM, like |
I think the above might be the source of the confusion. The above isn't an opt-out, it isn't a way of 'disabling' view transitions, it's just hiding them. All the events relating to the view transition still happen. It's like saying There isn't an opt-out for SPA transitions, because they're opt-in by calling Maybe the example in the article is misleading. It should really be a condition around calling Cross-document transitions should work in a similar way, by having an opt-in that you can make conditionally. I don't think we should have a system where the opt-in is big and dumb, and you have to hack around its big-and-dumbness by hiding loads of unintended transitions it creates.
I think you're getting too hung up on it being a boolean. The intention is for it to be conditional using existing features like media queries. And, like I pointed out in the other thread, its boolean form is just a shorthand for a block form.
The primary goal should be to allow for cross-document transitions to work exactly like SPA transitions. That's the feedback we got from Mozilla and developers. If you're going to take things in a different direction than that, it should come with good justification. Right now, with SPA transitions, you can easily add a class name to the root for the duration of the SPA transition. This allows the SPA transition to use particular names for that SPA transition. So, if there's a case where the SPA transition needs to use different names to cross-document transitions, that use-case is already catered for.
Fwiw, you could also do this with the option 2 at #8683, by using wildcard URLs. I'm not convinced it's useful, but being able to do it based on particular URLs is definitely useful.
That's a pretty bad smell around this proposal. You're having to create a
The meta tag was intended as a temporary hack. If you're wanting to keep it, you need to justify why it's a good part of the design. Since view transitions are a visual design feature, I really think the opt-in should be via CSS. The reason they're not opt-in via CSS for SPA transitions is the timing for the DOM change is already performed by JS, so |
Oh, I seem so to have missed that issue before. Reading that, I see the entire picture now:
Will chime in on #8683, as that better addresses my last question (number 5) earlier in this thread |
Yea I think I was going with this rather than #8683 because of #8683 (comment) but let's continue the discussion there. closing this one for now. |
In #8048, the proposal is to use a new rule for opting-in to cross-document transitions.
This has a few drawbacks:
body.disable-transitions { @cross-document-transitions: allow; }
::view-transitions { display: none }
)Proposing, instead, to use a media-query:
To accomplish the original requirement of disabling cross-doc transitions by default, the default UA stylesheet can be:
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:
We can also change the transition names based on whether this is a page transition:
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 aViewTransition
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.The text was updated successfully, but these errors were encountered: