Event Horizon

ProTransitionspowered by @vectorvesper/motion
Event Horizon

Included with membership

Members install Event Horizon with one command and get the full source, the usage code and the Framer remix, licensed for client work. One membership covers the whole library and the CLI.

When to use it

Moving between the pages of a site where the jump should feel like a moment: a portfolio, a magazine, a launch. It needs client-side navigation, such as router.push in Next.js or navigate in React Router. Keep it for the links that matter on a busy app, because a transition on every click soon tires.

  • Put the provider in a layout that stays mounted between pages, so a transition is not cut off half way.
  • Pass prefetch as well as navigate. Links then warm their page on hover and focus, so it is ready under the hole.
  • Use EventHorizonLink for links that should fall through, and navigate from useEventHorizon for buttons.
  • Pass the click point when you start a transition yourself, so the hole opens under the pointer.

Avoid:

  • Do not use it on pages that scroll inside an element instead of the window. The falling page is placed by the window's scroll, so it would show the top of the page.
  • Do not count on canvases or videos in the falling page. It is a copy of the old page, and copies of those can come out blank or start again.
  • Do not leave out navigate. Without it, links load the next page as usual and nothing animates.

Props

A page transition. When a visitor follows a link, the page they are on is pulled into the point they clicked: it bends towards that point, gathers into pleats and is swallowed, and the next page is already waiting underneath. Nothing runs between transitions.

<EventHorizonProvider />

Wraps the page and plays the transition. Renders its children inside a full-width element.

PropTypeDefaultDescription
childrenReact.ReactNode—The pages the transition plays between.
navigate(href: string) => unknown—Client-side navigation, e.g. `router.push` in Next.js or `navigate` in React Router. Without it, links do a full page load and nothing animates.
prefetch(href: string) => void—Warms a route before it is clicked, e.g. `router.prefetch`. Called on hover and focus.
durationnumber1100Length of the whole transition in milliseconds.
holeSizenumber0.15Width of the pull's centre as a fraction of the viewport's height, kept between 100 and 168 pixels. Smaller pulls the page in tighter.
suctionnumber1Suction force multiplier.
disabledbooleanfalseTurns the animation off; links still navigate.
onStart(href: string) => void—Called as a transition starts, with the destination.
onEnd(href: string) => void—Called once the new page has fully opened, or straight after a plain navigation.
classNamestring—Added to the element that wraps the page.

<EventHorizonLink />

A link that falls through the hole from where it was clicked. Takes any prop an anchor takes. Clicks with a modifier key, links that open a new tab and downloads behave as plain links.

PropTypeDefaultDescription
href*string—Where the link goes. Links to this site fall through the hole; any other link opens as usual.

<useEventHorizon />

hook

Starts a transition from code. Use it inside the provider; outside it, it throws.

PropTypeDefaultDescription
navigate*(href: string, at?: { x: number; y: number }) => void—Navigates to `href` through the hole. `at` is where the hole opens, in viewport pixels; the centre of the screen if left out.
prefetch*(href: string) => void—Warms a page before it is visited, through the provider's prefetch.
Visitors who prefer reduced motion get a plain page change with no animation. So does a link to another site, a link to the page already open, and any link while disabled is set.
It runs on the shared frame loop and claims the foreground while it plays, so other motion on the page gives way first. Between transitions it does no work at all.
Links opened from the keyboard open the hole at the link's centre. A click during a transition changes the page at once, without a second animation.
Client component. The provider renders its children on the server as they are; the transition only ever starts in the browser.
Back to all components