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: keep Crossfade Transition's pages that are not on show out of the accessibility tree, mark the current page name, and make its README snippet set both fades

matin7454b5c7921b
diff --git a/animations/03-page-transitions/crossfade/README.md b/animations/03-page-transitions/crossfade/README.md
index 23a98f40..6c010e8b 100644
--- a/animations/03-page-transitions/crossfade/README.md
+++ b/animations/03-page-transitions/crossfade/README.md
@@ -10,19 +10,21 @@ A crossfade switches pages by fading the old page out while the new one fades in
- Situations needing the calmest possible motion, since nothing moves, only opacity changes
## How it works
-In simultaneous mode both pages get the same-duration opacity transition and flip at once; in sequential mode each gets half the duration, staged one after the other. Both are ordinary CSS transitions on `opacity`:
+With Together, both pages get the same opacity transition and fade at once; with One after the other, each gets half the duration and the new page starts when the old one has gone. Both are ordinary CSS transitions on `opacity`:
```js
if(mode==='true'){
- // Simultaneous: both fade together over the full duration
+ // Together: both fade over the full duration
oldEl.style.transition=`opacity ${dur}ms ${ease}`;
newEl.style.transition=`opacity ${dur}ms ${ease}`;
oldEl.style.opacity='0'; newEl.style.opacity='1';
}else{
- // Sequential: fade old out over half, then new in over half
+ // One after the other: fade old out over half, then new in over half
const half=Math.round(dur/2);
+ oldEl.style.transition=`opacity ${half}ms ${ease}`;
oldEl.style.opacity='0';
setTimeout(()=>{
+ newEl.style.transition=`opacity ${half}ms ${ease}`;
newEl.style.opacity='0'; newEl.classList.add('active');
void newEl.offsetWidth; // commit the transparent start
newEl.style.opacity='1';
@@ -30,7 +32,7 @@ if(mode==='true'){
}
```
-Both pages are absolutely positioned in the same stacking context (`inset:0`), so they overlap perfectly and only their opacity changes. In simultaneous mode the outgoing page reaches ~0.5 exactly as the incoming page does, giving the momentary blend; in sequential mode the stage passes through a fully blank frame at the handoff.
+Both pages are absolutely positioned in the same stacking context (`inset:0`), so they overlap perfectly and only their opacity changes. With Together the outgoing page reaches ~0.5 exactly as the incoming page does, giving the momentary blend; with One after the other the stage passes through a fully blank frame at the handoff.
## Key parameters
| Parameter | Default | Effect |
@@ -41,7 +43,7 @@ Both pages are absolutely positioned in the same stacking context (`inset:0`), s
## Production notes
- **Stack both pages absolutely** so they occupy the same box. If they reflow the document, opacity alone won't give a clean blend.
-- **Simultaneous double-fade can look washed out** on light backgrounds, because two 50%-opacity layers over a bright backdrop sum brighter than either page. Sequential avoids this at the cost of a blank beat.
+- **The Together order can look washed out** on light backgrounds, because two 50%-opacity layers over a bright backdrop sum brighter than either page. One after the other avoids this at the cost of a blank beat.
- **A `+50ms` guard** after each `setTimeout` in the demo ensures the transition has finished before styles are reset; without slack the cleanup can clip the tail of the fade.
- **Reduced motion** swaps the `.active` class with no opacity transition at all.
- **Library equivalents**: this is the default `::view-transition-old/new(root)` behavior of the View Transitions API. Framer Motion's `AnimatePresence` with `initial/animate/exit` opacity, GSAP timelines, and React Transition Group all express the same overlap.
diff --git a/animations/03-page-transitions/crossfade/index.html b/animations/03-page-transitions/crossfade/index.html
index 8c748eef..5d86d15b 100644
--- a/animations/03-page-transitions/crossfade/index.html
+++ b/animations/03-page-transitions/crossfade/index.html
@@ -186,10 +186,12 @@
if(i>-1)timers.splice(i,1);
}
- function updateNav(n){navBtns.forEach((b,i)=>b.classList.toggle('active',i===n))}
- // One page's resting look: its class alone shows or hides it, with nothing left over from a fade (its background stays)
+ function updateNav(n){navBtns.forEach((b,i)=>{b.classList.toggle('active',i===n);b.setAttribute('aria-current',i===n?'page':'false')})}
+ // One page's resting look: its class alone shows or hides it, with nothing left over from a fade (its background stays).
+ // A page that is not shown is also out of the Tab order and the accessibility tree (inert).
function rest(el,on){
el.classList.toggle('active',on);
+ el.inert=!on;
el.style.transition='';el.style.opacity='';el.style.pointerEvents='';
}
// The resting state for page n, at once. A fade that is already running toward the same opacity keeps its own length
diff --git a/docs/superpowers/plans/2026-09-29-transitions-content.md b/docs/superpowers/plans/2026-09-29-transitions-content.md
index ec2f1b1a..404e1aed 100644
--- a/docs/superpowers/plans/2026-09-29-transitions-content.md
+++ b/docs/superpowers/plans/2026-09-29-transitions-content.md
@@ -377,18 +377,21 @@ None: leave out the `details.hb-options` block.
- [Slide Transition](../slide-transition/) — pages move sideways instead
- [Blur Transition](../blur-transition/) — a blur joins the fade
- **README How it works:**
- - The sentence "A `requestAnimationFrame` loop samples both computed opacities live so you can watch them cross:" becomes "Both are ordinary CSS transitions on `opacity`:".
- - In the snippet, `easeSel.value` becomes `ease`. In the sequential part, `requestAnimationFrame(()=>requestAnimationFrame(()=>{ newEl.style.opacity='1'; }));` becomes these two lines:
+ - The sentence "A `requestAnimationFrame` loop samples both computed opacities live so you can watch them cross:" becomes "With Together, both pages get the same opacity transition and fade at once; with One after the other, each gets half the duration and the new page starts when the old one has gone. Both are ordinary CSS transitions on `opacity`:". The README names the two orders as the page does, not "simultaneous" and "sequential".
+ - In the snippet, `easeSel.value` becomes `ease`, and the two comments read "Together: …" and "One after the other: …". In the One after the other part, `requestAnimationFrame(()=>requestAnimationFrame(()=>{ newEl.style.opacity='1'; }));` becomes these two lines:
```js
void newEl.offsetWidth; // commit the transparent start
newEl.style.opacity='1';
```
+ - The One after the other part also sets each page's transition, as the page does; read literally, the pages would snap without these lines. ``oldEl.style.transition=`opacity ${half}ms ${ease}`;`` goes before `oldEl.style.opacity='0';`, and ``newEl.style.transition=`opacity ${half}ms ${ease}`;`` is the first line inside the timer.
+ - The paragraph after the snippet uses the same two names: "With Together the outgoing page reaches ~0.5 … with One after the other the stage passes through a fully blank frame …".
- The rest is unchanged.
- **README Production notes:** unchanged
- **Category line:** `03.04 · Page Transitions`
- **Pager:** Previous: Morph Transition (`../morph-transition/`) · Next: Slide Transition (`../slide-transition/`)
+- **Final fix wave:** `rest()` sets `inert` on a page that is not on show, so a screen reader reads only the page on show and Tab cannot enter a hidden one; a page fading in becomes reachable when its fade ends, where `rest()` runs. The name of the page on show carries `aria-current="page"` and the other two `"false"` (`updateNav`). In the README's Production notes, the second bullet also uses the page's names for the two orders (it said "Simultaneous double-fade" and "Sequential"); it is the only change there.
---