← /lab
View Transitions
Moving around this site now has a direction. Going deeper slides the page in from the right, going back up slides it in from the left, and the navbar stays still. It uses the browser's View Transitions API through React's <ViewTransition>, with no animation library.
Try it
Go back to /lab (the page slides right), then open any experiment (it slides left). The ~ and /lab links in the corner work the same way.
Inside a page, a change can crossfade instead of jumping. Each card below is swapped inside a React transition:
Forward
Going deeper slides the page in from the right.
How it works
- Every link inside the site is a
NavLink. It compares where you are with where the link goes: a deeper path (/→/lab→/lab/x) tags the navigationnav-forward, a shallower onenav-back. The rule is a small tested function,navDirection. - Each page wraps its content in
PageTransition, which maps those two tags to a slide and fade. Next.js runs route changes as React transitions, so the browser snapshots the old page, React renders the new one, and CSS animates between them. - The navbar has its own transition name and no animation, so it stays put while only the content moves.
- With “reduce motion” turned on in your system settings, pages swap at once, without sliding.
Before and after
- Before, a page change swapped everything at once: nothing showed whether you went deeper or back.
- Now the old page leaves in 150 ms and the new one arrives over 400 ms. Navigation itself isn't slower: the new page is rendered first, then animated, and clicks still reach it during the animation.
Browser support and limits
- The directional slides need View Transition types and classes: Chrome and Edge 125+, and recent Safari and Firefox. Elsewhere pages change exactly as before, without animation.
- The browser's own back and forward buttons (and swipe gestures) carry no direction, so those changes don't slide.
- Moving between two experiments at the same depth doesn't slide either: neither is “deeper”.