Experiment with cross-document view transitions in Twenty Fifteen theme#8026
Experiment with cross-document view transitions in Twenty Fifteen theme#8026felixarntz wants to merge 9 commits intoWordPress:trunkfrom
Conversation
| window.addEventListener( 'pagereveal', async ( e ) => { | ||
| console.log( 'pageRevealEvent', e ); |
There was a problem hiding this comment.
For some reason, the pagereveal event is not fired in most of my page loads. I "randomly" see it fired, but rarely - no idea where that comes from.
I added the pageRevealEvent console log to ensure it has nothing to do with the e.viewTransition check below, so it's indeed the event itself that is not fired.
🤔
There was a problem hiding this comment.
I only see it fired when using the back/forward buttons in the browser.
There was a problem hiding this comment.
My guess is that the scripts that adds the event listener is called too late. It has to be added before the first rendering opportunity.
There was a problem hiding this comment.
I'm also seeing that MDN doesn't talk much about this, mind filing an issue?
pagereveal event listeners need to be added in either:
- A classic parser-blocking script at the head (not a module, not async, not defer)
- An async script in the head with
blocking=render, either module or classic.
There was a problem hiding this comment.
/cc @bramus, perhaps the cross-document view-transition official chromium docs should mention this if they don't already.
There was a problem hiding this comment.
Thanks for the ping @noamr. It’s not mentioned in our docs either (but all demos do use it that way). I remember being bitten by this myself, so would indeed be good to have some extra notices around this.
There was a problem hiding this comment.
Fixed in 3027a06, this was the problem indeed.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Closing this in favor of #8370, which now includes this behavior in a more abstract implementation that works across multiple themes and makes more sense. |
This is an experiment to use cross-document view transitions in WordPress, testing with the Twenty Fifteen theme.
For more context, see https://developer.chrome.com/docs/web-platform/view-transitions/cross-document
Trac ticket:
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.