Chasse.

04 / 13 ยท Web Animations API

Circle

The new page opens from the exact point you clicked.

Both pages are on screen and animate together.

The transition
// sync: the new page opens as a circle from where you clicked (visit.origin).
export const circle: TransitionHooks = {
  mode: 'sync',
  enter: ({ next, origin }) => {
    const x = origin?.x ?? innerWidth / 2
    const y = origin?.y ?? innerHeight / 2
    const radius = Math.hypot(Math.max(x, innerWidth - x), Math.max(y, innerHeight - y))
    const at = `at ${x}px ${onScreen(next).toPage(y)}px`
    return next.animate(
      { clipPath: [`circle(0px ${at})`, `circle(${radius}px ${at})`] },
      { duration: 1000, easing: 'cubic-bezier(0.65, 0, 0.35, 1)' },
    )
  },
}