Chasse.

07 / 13 ยท Web Animations API

Stack

The old page steps back and dims while the new one slides up over it.

Both pages are on screen and animate together.

The transition
// sync: the old page steps back and dims while the new one slides up over it, like a card stack.
const ease = 'cubic-bezier(0.65, 0, 0.35, 1)'

export const stack: TransitionHooks = {
  mode: 'sync',
  leave: ({ current }) => {
    current.style.transformOrigin = onScreen(current).center
    return current.animate(
      { transform: ['none', 'scale(0.92)'], opacity: [1, 0.3], borderRadius: ['0px', '28px'] },
      { duration: 900, easing: ease, fill: 'forwards' },
    )
  },
  enter: ({ next }) =>
    next.animate(
      { transform: ['translateY(100vh)', 'none'], borderRadius: ['28px 28px 0 0', '0px'] },
      { duration: 900, easing: ease },
    ),
}