-
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
Experiment with cross-document view transitions in Twenty Fifteen theme #8026
base: trunk
Are you sure you want to change the base?
Experiment with cross-document view transitions in Twenty Fifteen theme #8026
Conversation
window.addEventListener( 'pagereveal', async ( e ) => { | ||
console.log( 'pageRevealEvent', e ); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only see it fired when using the back/forward buttons in the browser.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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. |
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.