-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Call the view-transition page-visibility change steps #10137
Conversation
This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spec text looks good with a nit. Since this is a tricky area, I have some test questions.
Can you confirm:
-
It's tested that document's visibility state is updated before running the view transition page visibility change steps?
-
It's tested that view transition page visibility change steps come before firing visibilitychange?
-
Screen orientation change steps coming before view transition page-visibility steps is intentional, and implemented in Chromium? (Bonus points if you can test it, but I suspect it's not testable. Although https://github.com/web-platform-tests/wpt/blob/c399cf9e2773f36947383a12d90635562533a93c/screen-orientation/onchange-event.html#L20-L44 seems like maybe it's changing the orientation??)
Oops, testing the opposite :(
The order here doesn't matter and is not observable, as the screen orientation steps only apply when the document is visible and the view transition steps only apply when the document is hidden. |
- Change the order of operations when applying visibility change steps - Use InvalidStateError when skipping transition due to visibility - Use FromIfExist so that we don't create the VT supplementable unnecessarily See whatwg/html#10137 Bug: 330533269 Bug: 331237574 Change-Id: I2f9e66aecf5da6db01bb4c65d3f0b4c39563c142
I've received feedback internally that perhaps we should move this to after firing |
Can you expand on the reasoning? It seems we have a medium-strong precedent that |
For screen orientation and device posture, the visibility change steps queue a task to fire a different event. For WebNFC, some promises might be rejected which would be similar to this, but I'm not certain the order of operations is tested. So in essence, the consistent way of going about it would be to skip the transition after firing the event, or running them before but internally queuing a task to resolve the promises. Perhaps the latter is cleaner, but in terms of order of operations it's the same. |
Sorry ,that isn't enough detail for me. Can you help with
|
Imagine this code: const transition = document.startViewTransition();
onvisibilitychange = () => {
if (document.hidden) {
cleanupVisualStuffWhenHidden();
}
};
transition.finished.then(() => {
cleanupTransitionSpecificStuff();
});
/* After these are called, the user switches tabs or minimizes the window */ With the current spec PR, |
Thanks for explaining. Let's queue a task, then, as that gives implementations the most scheduling flexibility and is most consistent with what comes before. |
This doesn't change observable behavior, but makes the visibility reaction consistent with other similar reactions. See whatwg/html#10137
Done. (w3c/csswg-drafts#10168) |
…ask (#10168) This doesn't change observable behavior, but makes the visibility reaction consistent with other similar reactions. See whatwg/html#10137
This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden.
See w3c/csswg-drafts#9543
and CSSWG resolution: w3c/csswg-drafts#9543 (comment)
(See WHATWG Working Mode: Changes for more details.)
/infrastructure.html ( diff )
/interaction.html ( diff )