-
Notifications
You must be signed in to change notification settings - Fork 715
[css-view-transitions-2] Declaring when an MPA transition can start #8681
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
Comments
Yea I think we should have this, though without the event: document.activeTransition?.waitUntil(promise) |
I think the problem with that is it's unclear when calling With your proposal, it's a value that the UA is going to set and unset at some points, and without an event, there's no indication when it'll be set and unset. Also, when is it unset? Presumably when the transition stops being 'active', which means There's also an issue with naming. Would If the event is useful for other things, it might be worth using the event for this too, as it doesn't have the above issues. |
It will be set at document initialization and stay there until rendering is unblocked.
Also domUpdated doesn't exactly make sense in the MPA case. We can perhaps call it
It's useful but it has some gotchas, like what happens if rendering is cached so there's no rendering coming at all. I'm still pursuing it though. One thing I'm slightly concerned about with this event is that people would implement it with first-navigation in mind, and then create infinite-wait bugs for reactivate. Let's take the use case of blocking the transition until the hero image has loaded: e.g.: <head>
<script>
addEventListener('crossdocviewtransition', e => e.waitUntil(new Promise(resolve =>
document.addEventListener("load", loadEvent => {
if (loadEvent.target.id === 'hero')
resolve();
}, {capture: true})));
</script>
</head> Of course it's simple to fix this, but also easy to overlook this - it would work great when you run it locally, but then when you have BFCache/prerender it would wait forever. What I'm getting at is, I'm not sure we should have an event that abstract away the difference between reactivation and initial render with an event that fires in both. You have an event for the former and the latter is a synchronous script in |
That seems reasonable. I was confused by the naming initially, since 'active' has a wider scope. I think there's a more general feature here around blocking rendering, so I'd advise splitting this into two parts:
However, it's worth considering if there are cases where the developer would want to control render blocking when the page is coming out of bfcache.
This is discussed in #8682. I really recommend catching up with the current state of the design. A lot of this stuff has already been discussed internally and with CSSWG folks like Tab. I'm not saying that the design is perfect, or even good, but I think there's value in at least reading it.
Sighhhhh we really should have promises for this stuff.
But you also don't want transitions that fail or look faulty on certain kinds of traversal, because the developer has to add extra code for bfcache transitions, and they didn't test that bit. That said, I agree that in regards to render blocking, what you'd do for initial load is different to coming out of bfcache. I think the best way to approach is to look at render blocking as a more general feature. |
Yea I went through all of it but it's spread over a couple of dozens of issues so I'm sure I missed some points. Will catch up on that one.
Right, this is exactly where I'm at... Before we get to a general-purpose potential-footgun, let's try to fix this more from the use case site and see what the need is afterwards. |
This is handled in the spec draft. |
I don't think MPA transitions should delay the swap from the old to new document by default. Instead, the transition should happen on first render. This means, when the transition starts, the page may not have fully parsed, and things like images may not have loaded.
With SPA, you can preload assets before calling
startViewTransition
. With MPA, you can use prerender, but you don't get feedback when the prerender is 'ready'.Blocking attributes can be used by the incoming page to delay the document swap. However, these attributes currently only apply to script/stylesheets. We could expand the set of elements they apply to, such as images and preload. We could add a special blocking value "
view-transition
", so the blocking only applies if a view transition is being attempted.We could also allow first render to be delayed by JavaScript:
Although we'd want to avoid infinite delays, like we already do with
startViewTransition
.The text was updated successfully, but these errors were encountered: