06 / 13 ยท Web Animations API
Zoom
The old page shrinks away and the new one settles in from slightly larger.
The old page leaves, then the new page enters.
// out-in: the old page shrinks away, the new page settles in from slightly larger.
export const zoom: TransitionHooks = {
mode: 'out-in',
leave: ({ current }) => {
current.style.transformOrigin = onScreen(current).center
return current.animate(
{ transform: ['none', 'scale(0.96)'], opacity: [1, 0] },
{ duration: 380, easing: 'cubic-bezier(0.4, 0, 1, 1)', fill: 'forwards' },
)
},
enter: ({ next }) => {
next.style.transformOrigin = onScreen(next).center
return next.animate(
{ transform: ['scale(1.04)', 'none'], opacity: [0, 1] },
{ duration: 600, easing: 'cubic-bezier(0.16, 1, 0.3, 1)' },
)
},
}