Different Page Transitions For Different Circumstances
frontendmasters.com·1w
Preview
Report Post

I feel like common usage for multi-page view transitions is to set up a general system for them that applies generally to all pages and elements, then let it ride.

But I just recently saw the DOM events in JavaScript and how they can be used to set a “type”. So check out the events first:

// The old / unloading page
window.addEventListener('pageswap', async (e) => {
if (e.viewTransition) {

}
}

// the new / loading page
window.addEventListener('pagereveal', async (e) => {
if (e.viewTransition) {

}
}Code language: JavaScript (javascript)

You can do anything you might want in there, but an especially interesting thing to me is that you can set the view transition type, and do so *conditionally. *

Customize the View Transition Type for One Particular URL

Just to clearly …

Similar Posts

Loading similar posts...