-
Notifications
You must be signed in to change notification settings - Fork 689
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
Interaction with Safari's back/forward previews #8333
Comments
This is an issue even without View Transitions, an SPA could do custom transitions with any internal framework. |
Also doesn't need to be an SPA :) click any of big titles and then swipe for a back preview : There is no way to tell Safari when it should create these previews. We never found a way to make these previews work properly and have transitions. |
@romainmenke, I'm able to repro the issue on the site above. Do you mind clarifying the timing of the animation with the navigation? What event do you use to trigger the animation? I'm seeing 2 classes of problems with these default transitions. I think solving Double Transition is easier so we could start with the small API proposal for it below. @domenic @annevk thoughts? Double Transition window.addEventListener('popstate', (event) => {
if (event.hasBrowserTransition) {
navigateOnly();
return;
}
navigateAndAnimate();
});
navigation.addEventListener('navigate', (event) => {
if (event.hasBrowserTransition) {
navigateOnly();
return;
}
navigateAndAnimate();
}); Incorrect Capture
This is harder to solve. We could add a hook where the browser informs the page that it will be captured for a preview and should set up state accordingly. But given case 3 above, it's not deterministic what the user will see at the time the browser would ideally do a capture (the last frame rendered by the outgoing page). |
In short :
We have to be careful to undo the outro when a user navigates back but other than that it is a fairly simple setup. Browsers avoid a flash of white in between navigations, so it appears to be seamless like an SPA transition. But it is just Because this is al just hacks there is no way for Safari to "understand" that we are playing an outro. It captures the back preview when the actual navigation happens, not when the user clicks the link. We would never implement anything like this if there was a native API for transitions of this kind. Today there is no native way. |
Got it, so you consume the click to do an animation and then trigger the navigation.
Glad to hear this. So a primitive like cross-document ViewTransitions would help. If the animation is expressed using a browser primitive, then the browser knows what to capture. |
Filed whatwg/html#8782 with a proposal |
@fantasai This issue is still on our priority list, whatwg/html#8782 was discussed at the html triage meeting and we're waiting for feedback from other implementors. I don't think this needs to be a blocker for VT L1 though. Interaction with UA transitions is a problem irrespective of View Transitions, since authors can create them for same-document navigations with a framework other than VT. And conversely, VT has no way of knowing if a transition is in response to a navigation or just any DOM change. Sounds reasonable? |
Chatted with @fantasai offline. The solution for this problem is tracked in whatwg/html#8782 and #8747 but I'm putting this on the agenda to confirm with the group that VT L1 doesn't need to block on this. |
I'll close this in favour of whatwg/html#8782 which addresses the problem described in this issue. The API addition will need to be in the html spec. |
Unfortunately view transitions do not work correctly with finger swipes that go forward / backward in history. See these issues for more details: - w3c/csswg-drafts#8333 - whatwg/html#8782 - w3c/csswg-drafts#8747
Both Safari iOS and Safari Desktop have a feature where you see a 'preview' of the previous history entry when you drag from the edge (iOS) or two-finger swipe (Desktop). This includes same-document traversals.
out.mp4
safari-desktop.mp4
This already causes issues in cases where developers have created their own transition. Demo: https://static-misc-3.glitch.me/basic-navigation-transition/. Here's what happens:
popstate
event, so they begin a transition from "state 1" to "state 2", meaning it looks like things 'snap back' to "state 2".out.mp4
It feels like we should avoid this kind of experience with view transitions (both SPA and MPA) at least.
I think a good starting point is: Is there something developers should be doing today to avoid this kind of experience in Safari? If not, we can invent something 😀
@smfr any ideas around this? It seems to be a problem in the wild https://twitter.com/ryanflorence/status/1362095580827160578
The text was updated successfully, but these errors were encountered: