05 / 13 ยท Web Animations API
Wipe
A clean top-to-bottom reveal while the old page drifts up.
Both pages are on screen and animate together.
// sync: the new page is revealed top to bottom while the old one drifts up.
const ease = 'cubic-bezier(0.65, 0, 0.35, 1)'
export const wipe: TransitionHooks = {
mode: 'sync',
leave: ({ current }) =>
current.animate({ transform: ['none', 'translateY(-12vh)'], opacity: [1, 0.4] }, { duration: 900, easing: ease, fill: 'forwards' }),
enter: ({ next }) => {
const { above, below } = onScreen(next)
const shown = next.offsetHeight - above
return next.animate(
{ clipPath: [`inset(0 0 ${shown}px 0)`, `inset(0 0 ${below}px 0)`] },
{ duration: 900, easing: ease },
)
},
}