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 the Fast flash to three a second or fewer

matina0925a1ecf2f
diff --git a/animations/03-page-transitions/flash-transition/README.md b/animations/03-page-transitions/flash-transition/README.md
index d5e600ff..46ddb0d8 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`. 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`. 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.
## Key parameters
| Parameter | Default | Effect |
diff --git a/animations/03-page-transitions/flash-transition/index.html b/animations/03-page-transitions/flash-transition/index.html
index f019e62d..f32e1b16 100644
--- a/animations/03-page-transitions/flash-transition/index.html
+++ b/animations/03-page-transitions/flash-transition/index.html
@@ -173,6 +173,9 @@
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=[];
const pages=[],navBtns=[];
@@ -249,7 +252,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,flashOut);
+ later(finish,Math.max(flashOut,MIN_CYCLE-flashIn));
},flashIn);
}