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.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
fix: keep Flash / Light Leak Transition to three flashes a second for every input
matinea9b686ca0b3
diff --git a/animations/03-page-transitions/flash-transition/README.md b/animations/03-page-transitions/flash-transition/README.mdindex 46ddb0d8..b4bafa0e 100644--- a/animations/03-page-transitions/flash-transition/README.md+++ b/animations/03-page-transitions/flash-transition/README.md@@ -26,7 +26,7 @@ function doTransition(prev, next) {}```-The fade-out sets its own transition in the same step as the new opacity, so it runs over `flashOut` rather than `flashIn`. A flash also lasts at least 350ms from the start of its rise, so however fast the pages are clicked the demo never flashes more than three times a second. An optional `blur()` filter applied during the flash softens the edge and sells the light-leak feel.+The fade-out sets its own transition in the same step as the new opacity, so it runs over `flashOut` rather than `flashIn`. No flash starts less than half a second after the previous one began, whatever is pressed (page names, Show me or Reset), so the demo never flashes more than twice a second; a change asked for sooner waits for that moment with the overlay clear. An optional `blur()` filter applied during the flash softens the edge and sells the light-leak feel.## Key parameters| Parameter | Default | Effect |diff --git a/animations/03-page-transitions/flash-transition/index.html b/animations/03-page-transitions/flash-transition/index.htmlindex f32e1b16..dcda2635 100644--- a/animations/03-page-transitions/flash-transition/index.html+++ b/animations/03-page-transitions/flash-transition/index.html@@ -173,10 +173,10 @@const nav=document.getElementById('nav'),area=document.getElementById('page-area'),flashEl=document.getElementById('flash-overlay');const blurTog=document.getElementById('blur-tog'),slowTog=document.getElementById('slow-tog');const motionOk=!window.matchMedia('(prefers-reduced-motion:reduce)').matches;- // A flash lasts at least this long (ms) from the start of its rise, so the next one starts no sooner: never more than three- // a second, however fast the visitor clicks. Only Fast (310ms) is stretched.- const MIN_CYCLE=350;- let current=0,animating=false,flashIn=200,flashOut=320,intensity=1,afterMove=null,wayBack=0,timers=[];+ // No flash starts less than this many ms after the last one began, whatever the visitor presses (page names, Show me, Reset):+ // never more than two flashes a second. A change asked for sooner waits, with the overlay clear, until then.+ const MIN_CYCLE=500;+ let current=0,animating=false,flashIn=200,flashOut=320,intensity=1,lastRise=-MIN_CYCLE,afterMove=null,wayBack=0,timers=[];const pages=[],navBtns=[];PAGES.forEach((p,i)=>{@@ -237,6 +237,14 @@afterMove=then||null;if(!motionOk){showPage(next);finish();return}animating=true;+ // settle() cancels a wait, and the next change measures from the same lastRise, so no input can start two rises too close+ // together+ const wait=MIN_CYCLE-(performance.now()-lastRise);+ if(wait>0)later(()=>flash(prev,next),wait);else flash(prev,next);+ }++ function flash(prev,next){+ lastRise=performance.now();const scale=slowTog.checked?3:1;doTransition(prev,next,flashIn*scale,flashOut*scale);}@@ -252,7 +260,7 @@pages[next].classList.add('active');flashEl.style.transition=`opacity ${flashOut}ms ease-out, filter ${flashOut}ms ease`;flashEl.style.opacity='0';flashEl.classList.remove('blur-on');- later(finish,Math.max(flashOut,MIN_CYCLE-flashIn));+ later(finish,flashOut);},flashIn);}diff --git a/docs/superpowers/plans/2026-09-29-transitions-content.md b/docs/superpowers/plans/2026-09-29-transitions-content.mdindex 8e3ca855..a7aac576 100644--- a/docs/superpowers/plans/2026-09-29-transitions-content.md+++ b/docs/superpowers/plans/2026-09-29-transitions-content.md@@ -564,6 +564,11 @@ None: leave out the `details.hb-options` block.- `hb:input` cancels the way back.- **Reset:** yes. Home at once. The overlay's transition is turned off, its opacity set to 0 and `blur-on` removed.- **Slow motion:** multiplies `flashIn` and `flashOut` by 3, along with their timers.+- **Flash rate:** never more than two flashes a second, however the visitor presses (WCAG 2.3.1, level A, allows three; the floor keeps a margin, because a flash that Show me or Reset cuts short peaks where it is cut, which can bring the peaks of two flashes closer together than their starts).+ - No rise starts less than 500ms after the previous rise began (`MIN_CYCLE`). The page keeps the time of the last rise (`lastRise`).+ - A change asked for sooner waits, with the overlay at 0 and the pages unchanged, and its rise starts when the 500ms are over. `settle()` cancels a waiting rise, and the next change measures from the same `lastRise`, so no input can start two rises too close together. This covers page names, Show me (clicked, or held with the key repeating) and Reset followed by a page name.+ - `settle()` still puts the demo at rest at once (the overlay is at 0 immediately); only a new rise waits. A waiting rise belongs to the change under way, so `hb:input` does not cancel it.+ - In normal use the wait is not noticed: nothing waits at Normal (520ms a flash) or Slow (830ms), a Show me run holds 1200ms between its flashes, and at Fast (310ms a flash) a page name clicked right after a flash waits at most 190ms. It matters when Show me or Reset is pressed over and over. The fade-out timer stays `flashOut`.- **Reduced motion:** the demo's rule `#flash-overlay{display:none}` and its `motionOk` branch stay: the pages swap at once with no flash. Show me swaps to Work and back.- **Stage font:** site font.- **Stage:**@@ -623,6 +628,7 @@ None: leave out the `details.hb-options` block.- **README How it works:**- In the snippet, the `requestAnimationFrame(() => {` line and its closing `});` go. The two fade-out lines they held stay in the timer callback, right after the page swap.- The sentence "The swap is deferred to a `requestAnimationFrame` after the class change so the browser commits the new transition before starting the fade-out." becomes "The fade-out sets its own transition in the same step as the new opacity, so it runs over `flashOut` rather than `flashIn`."+ - One sentence follows it: "No flash starts less than half a second after the previous one began, whatever is pressed (page names, Show me or Reset), so the demo never flashes more than twice a second; a change asked for sooner waits for that moment with the overlay clear."- **README Production notes:** unchanged- **Category line:** `03.07 · Page Transitions`- **Pager:** Previous: Zoom Transition (`../zoom-transition/`) · Next: Blur Transition (`../blur-transition/`)