Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

fix: hide View Transitions API's pages that are not shown, mark the current page name, and correct its Production notes

matin9f91be2b881b
diff --git a/animations/03-page-transitions/view-transitions-api/README.md b/animations/03-page-transitions/view-transitions-api/README.md
index 8507ca5e..de4dbe15 100644
--- a/animations/03-page-transitions/view-transitions-api/README.md
+++ b/animations/03-page-transitions/view-transitions-api/README.md
@@ -49,10 +49,12 @@ Switching the `data-vt` attribute swaps in a different keyframe set (slide, zoom
## Production notes
- **Feature-detect** with `'startViewTransition' in document` and fall back to a manual opacity cross-fade — the demo does exactly this, so browsers without the API still get a simple 300ms fade, whatever the Transition style and Speed.
+- **Browser support.** Same-document view transitions — `document.startViewTransition()`, as in this demo — work in Chrome and Edge 111 and later, Safari 18 and Firefox 144. Cross-document ones, turned on for full page loads with `@view-transition { navigation: auto; }`, work in Chrome and Edge 126 and Safari 18.2; check current support for Firefox. Keep the fallback for older browsers.
- **Suppress the root animation** (`::view-transition-old(root)`) when you only want a sub-region to animate; otherwise the whole page cross-fades underneath your named region.
-- **Every `view-transition-name` must be unique** on the page at capture time. Two elements sharing a name in the same snapshot throws and aborts the transition.
+- **Every `view-transition-name` must be unique** on the page at capture time. Two elements sharing a name in the same snapshot make the browser skip the transition: the page still changes, with no animation.
- **Honor reduced motion** — the demo drops straight to `showPage()` with no animation when `prefers-reduced-motion: reduce` is set.
-- **Library equivalents**: Astro's `<ViewTransitions />` and Next.js's experimental view-transition support wrap this API for cross-document navigation. Barba.js and Swup predate it and polyfill the same idea with manual snapshotting; on supported browsers you often no longer need them.
+- **Presses wait for the transition.** While a view transition runs, Chrome sends every press on the page to the root element, so buttons do not respond until it ends (`pointer-events` on the transition's pseudo-elements does not change this); keep page transitions short. The demo passes a press over its box on as the visitor taking over, so a click there still stops Show me.
+- **Library equivalents**: Astro's `<ClientRouter />` (named `<ViewTransitions />` before Astro 5) and React's experimental `<ViewTransition>` component, which Next.js can switch on, wrap this API for client-side page changes; between full page loads the CSS rule `@view-transition { navigation: auto; }` does it without JavaScript. Barba.js and Swup predate the API and animate the old and new page content themselves; on supported browsers you often no longer need them.
## See also
- [Crossfade Transition](../crossfade/) — the same fade, built by hand
diff --git a/animations/03-page-transitions/view-transitions-api/index.html b/animations/03-page-transitions/view-transitions-api/index.html
index a300980d..0350bf3d 100644
--- a/animations/03-page-transitions/view-transitions-api/index.html
+++ b/animations/03-page-transitions/view-transitions-api/index.html
@@ -220,14 +220,14 @@
if(i>-1)timers.splice(i,1);
}
- function updateNav(n){navBtns.forEach((b,i)=>b.classList.toggle('active',i===n))}
- // The resting state for page n: it shows, the others are hidden, and no transition leaves a style behind
+ function updateNav(n){navBtns.forEach((b,i)=>{b.classList.toggle('active',i===n);b.setAttribute('aria-current',i===n?'page':'false')})}
+ // The resting state for page n: it shows, the others are hidden and inert, and no transition or fade is left running
function showPage(n){
pages.forEach((el,i)=>{
- el.classList.toggle('active',i===n);
+ el.classList.toggle('active',i===n);el.inert=i!==n;
el.style.cssText='';
el.style.background=PAGES[i].bg;
- el.style.opacity=i===n?'1':'0';
+ el.style.opacity=i===n?'1':'0';el.getAnimations().forEach(a=>a.cancel());
});
}
diff --git a/docs/superpowers/plans/2026-09-29-transitions-content.md b/docs/superpowers/plans/2026-09-29-transitions-content.md
index 84b798b2..1d35903b 100644
--- a/docs/superpowers/plans/2026-09-29-transitions-content.md
+++ b/docs/superpowers/plans/2026-09-29-transitions-content.md
@@ -88,8 +88,8 @@ Eight demos put an element in its starting state with `transition:none` and star
- `settle()` calls `skipTransition()` on a view transition still running and marks the demo idle at once. The old navigation's `await t.finished` must then not run its end code; a run counter compared after the `await` handles this.
- A view transition skipped while the browser is still taking its first picture still runs its update callback afterwards. With today's `switchPage(prev,next)` that callback could undo a Reset made in the same frame, so the update callback shows the resting state for `current` as it is when the callback runs (`startViewTransition(()=>showPage(current))`), not the pages the navigation started with.
- `hb:input` cancels the way back. A view transition already running finishes.
- - Note for the builder: while a view transition runs (half a second at Normal), the browser's transition layer covers the page, so a press may land on the page root instead of the stage and send no `hb:input`; a press then does not cancel the way back. Check this in the browser during the conversion.
-- **Reset:** yes. Home at once; a running view transition is skipped first.
+ - **Presses during a view transition.** While a view transition runs (half a second at Normal), Chrome sends every press on the page to the root element (`<html>`), so the shared script never hears a press on the stage and no `hb:input` is sent. The page therefore listens for `pointerdown` and `click` on the root (capture phase, passive): when the event is trusted, its target is the root, the page's own view transition is running and the point lies inside the stage, it sends the same `hb:input` event, so a click on the stage during a transition still cancels the way back. Presses on the player bar (Show me, Reset, Slow motion) do nothing until the transition ends, and `::view-transition{pointer-events:none}` does not change that (checked in Chrome, on the top pseudo-element and on every view-transition pseudo-element); the README's Production notes say so.
+- **Reset:** yes. Home at once; a running view transition is skipped first, and without the API a fallback fade still running is cancelled.
- **Slow motion:** each navigation sets `--vt-dur` to Speed × 3 before it starts the view transition. The fallback crossfade for browsers without the API is stretched too: its 300ms fade becomes 900ms, and its 350ms wait becomes 950ms.
- **Reduced motion:** the demo's rule (`::view-transition-old(page-content),::view-transition-new(page-content){animation:none}`) and its `motionOk` branch (`switchPage()` at once) stay. Show me swaps to Work and back with no movement.
- **Stage font:** site font.
@@ -144,10 +144,15 @@ Eight demos put an element in its starting state with `transition:none` and star
- [Slide Transition](../slide-transition/) — pages slide, with a sense of direction
- [Zoom Transition](../zoom-transition/) — three ways to zoom between pages
- [Shared Element Transition](../shared-element-transition/) — one picture grows into the next page
-- **README How it works:** unchanged
-- **README Production notes:** the support banner is gone, so the first bullet says what browsers without the API see: "the demo does exactly this so unsupported browsers still transition." becomes "the demo does exactly this, so browsers without the API still get a simple 300ms fade, whatever the Transition style and Speed." The rest is unchanged.
+- **README How it works:** follows the code (`showPage(current)`, `--vt-dur`, the skipped-transition sentence).
+- **README Production notes:** the support banner is gone, so the first bullet says what browsers without the API see: "the demo does exactly this so unsupported browsers still transition." becomes "the demo does exactly this, so browsers without the API still get a simple 300ms fade, whatever the Transition style and Speed." The rest changes as follows:
+ - **Browser support** is a new bullet after Feature-detect: "Same-document view transitions — `document.startViewTransition()`, as in this demo — work in Chrome and Edge 111 and later, Safari 18 and Firefox 144. Cross-document ones, turned on for full page loads with `@view-transition { navigation: auto; }`, work in Chrome and Edge 126 and Safari 18.2; check current support for Firefox. Keep the fallback for older browsers." The versions were checked against MDN's compatibility data for `Document.startViewTransition()`, `ViewTransition` and `@view-transition` (Firefox has no cross-document support yet).
+ - The unique-name bullet now says two elements sharing a name "make the browser skip the transition: the page still changes, with no animation" (it said this "throws and aborts the transition").
+ - **Presses wait for the transition** is a new bullet before the library line: "While a view transition runs, Chrome sends every press on the page to the root element, so buttons do not respond until it ends (`pointer-events` on the transition's pseudo-elements does not change this); keep page transitions short. The demo passes a press over its box on as the visitor taking over, so a click there still stops Show me."
+ - **Library equivalents** is rewritten: "Astro's `<ClientRouter />` (named `<ViewTransitions />` before Astro 5) and React's experimental `<ViewTransition>` component, which Next.js can switch on, wrap this API for client-side page changes; between full page loads the CSS rule `@view-transition { navigation: auto; }` does it without JavaScript. Barba.js and Swup predate the API and animate the old and new page content themselves; on supported browsers you often no longer need them." (The old line said Astro and Next.js wrapped it for cross-document navigation, and that Barba.js and Swup work by taking snapshots.)
- **Category line:** `03.01 · Page Transitions`
- **Pager:** Previous: none · Next: Shared Element Transition (`../shared-element-transition/`)
+- **Final fix wave:** the page names carry `aria-current` (`"page"` on the shown page's name, `"false"` on the others); `showPage` makes the pages not shown `inert` and cancels any transition or fade still running on them, so Reset also stops the fallback fade; the README's Production notes gain browser support and the presses-wait note, and lose three wrong statements (duplicate names, the Astro and Next.js line, snapshots).
---