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: Theme Toggle Morph: Compare's posed moment stays under nine tenths of the change, so Springy's second half is still caught part way

matinc1a5c0f8b745
diff --git a/animations/04-micro-interactions/theme-toggle-morph/index.html b/animations/04-micro-interactions/theme-toggle-morph/index.html
index f45d7cbd..70325ce9 100644
--- a/animations/04-micro-interactions/theme-toggle-morph/index.html
+++ b/animations/04-micro-interactions/theme-toggle-morph/index.html
@@ -359,11 +359,12 @@
return at(b,e,t);
}
// Compare's moment: the real half a fifth of a second after a press at full speed (Slow motion leaves it as it is), on top of a
- // theme that is still light. The page's time and curve give --p; the transitions are off while it is drawn.
+ // theme that is still light. The page's time and curve give --p, held under 0.9 so a curve that is already done or past it by
+ // then (Springy, or Fast) still leaves the half part way; the transitions are off while it is drawn.
const PEEK=200;
function pose(){
noTransition(true);
- stage.style.setProperty('--p',curveAt(ease,Math.min(1,PEEK/dur)).toFixed(3));
+ stage.style.setProperty('--p',Math.min(.9,curveAt(ease,Math.min(1,PEEK/dur))).toFixed(3));
stage.classList.add('posed');twin.classList.add('dark');
void stage.offsetWidth;noTransition(false);
posed=true;note();