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: Scrub Animation: Back to top puts Compare's left plane at the start even when the box is already at the top

Claude5c956aceb7b0
diff --git a/animations/01-scroll-based/scrub-animation/index.html b/animations/01-scroll-based/scrub-animation/index.html
index 47745f44..9e2959c0 100644
--- a/animations/01-scroll-based/scrub-animation/index.html
+++ b/animations/01-scroll-based/scrub-animation/index.html
@@ -335,7 +335,7 @@
document.addEventListener('visibilitychange', () => { lastT = null; });
// Back to top, and Play pressed at the end (it starts again from the top), are jumps: both planes stand at the start at once.
// These listeners come before the shared script's, so they see the box where it was.
- const jump = () => { q = qt = 0; stopFlight(); };
+ const jump = () => { q = qt = 0; stopFlight(); if (mode === 'compare') draw(TWIN, 0); }; // no scroll event follows when the box is already at the top
$('btn-top').addEventListener('click', jump);
$('btn-scroll').addEventListener('click', () => { if (stage.scrollTop >= stage.scrollHeight - stage.clientHeight - 2) jump(); });