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.

docs: match the transition READMEs' snippets to the code

matina0ac19236011
diff --git a/animations/03-page-transitions/blur-transition/README.md b/animations/03-page-transitions/blur-transition/README.md
index 2dccd9d2..7c627f91 100644
--- a/animations/03-page-transitions/blur-transition/README.md
+++ b/animations/03-page-transitions/blur-transition/README.md
@@ -13,19 +13,21 @@ A blur transition takes the old page out of focus until it disappears, then brin
The outgoing page transitions its `filter` (and optionally `opacity`) up to a maximum blur, then the incoming page is pre-blurred, made active, and transitioned back to `blur(0px)`. Because filter transitions do not compose across an element swap, the incoming page's blur is set with `transition: none`, forced to commit with a reflow, and only then animated to sharp.
```js
-function doTransition(prev, next) {
+function doTransition(prev, next, dur, ease, maxBlur) {
const o = pages[prev], n = pages[next];
- o.style.transition = `filter ${dur}ms ${ease}, opacity ${dur}ms ${ease}`;
+ const withFade = fadeTog.checked, overlap = overlapTog.checked;
+ const t = `filter ${dur}ms ${ease}` + (withFade ? `, opacity ${dur}ms ${ease}` : '');
+ o.style.transition = t;
o.style.filter = `blur(${maxBlur}px)`;
if (withFade) o.style.opacity = '0';
const swapAfter = overlap ? Math.round(dur * 0.5) : dur;
setTimeout(() => {
- o.classList.remove('active');
+ o.classList.remove('active'); o.style.opacity = '0';
n.style.transition = 'none';
n.style.filter = `blur(${maxBlur}px)`; n.style.opacity = '0'; n.classList.add('active');
void n.offsetWidth; // commit the blurred start
- n.style.transition = `filter ${dur}ms ${ease}, opacity ${dur}ms ${ease}`;
+ n.style.transition = t;
n.style.filter = 'blur(0px)'; n.style.opacity = '1'; // sharpen in
}, swapAfter);
}
diff --git a/animations/03-page-transitions/flash-transition/README.md b/animations/03-page-transitions/flash-transition/README.md
index b4bafa0e..3c8bfa79 100644
--- a/animations/03-page-transitions/flash-transition/README.md
+++ b/animations/03-page-transitions/flash-transition/README.md
@@ -13,8 +13,9 @@ A flash transition hides a page change inside a burst of light. A colored layer
A single absolutely-positioned overlay sits above the pages at a high `z-index`. The transition runs in three phases driven by two `setTimeout` calls: fade the overlay up over `flashIn`, swap the active page at peak opacity, then fade the overlay back down over `flashOut`. The content change happens while the overlay is opaque, so it is invisible.
```js
-function doTransition(prev, next) {
+function doTransition(prev, next, flashIn, flashOut) {
flashEl.style.transition = `opacity ${flashIn}ms ease-in, filter ${flashIn}ms ease`;
+ flashEl.classList.toggle('blur-on', blurTog.checked); // the optional glow
flashEl.style.opacity = intensity; // fade the flash up
setTimeout(() => {
// Peak — swap the page behind the opaque flash
@@ -22,6 +23,7 @@ function doTransition(prev, next) {
pages[next].classList.add('active');
flashEl.style.transition = `opacity ${flashOut}ms ease-out, filter ${flashOut}ms ease`;
flashEl.style.opacity = '0'; // fade the flash down to reveal
+ flashEl.classList.remove('blur-on');
}, flashIn);
}
```