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: lesson 21 keeps each layer's place as a share of the window width, so resizing while paused cannot strand a layer, and under reduced motion the loop never starts before the shared script pauses it
matin3a94b3604c17
diff --git a/learn/far-things-move-slower/index.html b/learn/far-things-move-slower/index.htmlindex 93bedd7c..5b57f264 100644--- a/learn/far-things-move-slower/index.html+++ b/learn/far-things-move-slower/index.html@@ -154,6 +154,8 @@const strips = [...stage.querySelectorAll('.strip')];const tags = [...stage.querySelectorAll('.speed')];const same = document.getElementById('same');+ // How far each layer has slid, in window widths: 0 to 1, then it starts over. Not in pixels, so a window that is resized+ // while the page is paused cannot leave a layer outside the stageconst pos = strips.map(() => 0);let lastT = null, raf = 0, paused = false;@@ -161,10 +163,10 @@function frame(ts) {const dt = lastT === null ? 0 : Math.min(ts - lastT, 50);lastT = ts;- const w = stage.clientWidth;strips.forEach((s, i) => {- pos[i] = (pos[i] + speedOf(i) * w / 60 * (dt / FRAME)) % w;- s.style.transform = `translate3d(${-pos[i].toFixed(2)}px,0,0)`;+ pos[i] = (pos[i] + speedOf(i) / 60 * (dt / FRAME)) % 1;+ // A layer is two windows wide, so half of its own width is one window: the whole loop+ s.style.transform = `translate3d(${(-pos[i] * 50).toFixed(3)}%,0,0)`;});raf = requestAnimationFrame(frame);}@@ -186,7 +188,8 @@}same.addEventListener('change', describe);describe();- start();+ // Under reduced motion the scene waits for Play (the shared script pauses it too, but only once it has loaded)+ if (!matchMedia('(prefers-reduced-motion: reduce)').matches) start();</script></body></html>