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: replay the text pages from the start on every play

matin429eae52929e
diff --git a/animations/02-entrance-and-exit/letter-by-letter-stagger/index.html b/animations/02-entrance-and-exit/letter-by-letter-stagger/index.html
index d59e1d1d..1385cdac 100644
--- a/animations/02-entrance-and-exit/letter-by-letter-stagger/index.html
+++ b/animations/02-entrance-and-exit/letter-by-letter-stagger/index.html
@@ -183,9 +183,9 @@
vars.setProperty('--dur',dur()+'ms');
vars.setProperty('--stagger',stag()+'ms');
}
- // Rebuilds the letters (and the cursor, in Typewriter) from the current style, cursor choice and
- // text. Runs immediately when Style, Blinking cursor or Your text changes, so the stage never shows
- // a stale phrase, and again whenever a play clears the letters back to hidden.
+ // Rebuilds the letters (and the cursor, in Typewriter), hidden, from the current style, cursor choice and
+ // text. Runs at the start of every Cascade play and when the Loop clears the phrase, and at once when
+ // Style, Blinking cursor or Your text changes so the stage never shows a stale phrase.
function buildSpans(){
target.classList.remove('done');
const text=txtIn.value||'Hello, world.';
@@ -208,8 +208,8 @@
return mode==='cascade'?n*stag()+dur():n*stag();
}
function playCascade(){
- // snap back to hidden without a transition so every play settles in again
- target.classList.remove('done');void target.offsetWidth;
+ // rebuild the letters hidden, then show them after a reflow, so every play settles them in from the start
+ buildSpans();void target.offsetWidth;
target.classList.add('done');
}
function playTypewriter(){
diff --git a/animations/02-entrance-and-exit/split-text-reveal/index.html b/animations/02-entrance-and-exit/split-text-reveal/index.html
index a4d82cce..a8b1c2d6 100644
--- a/animations/02-entrance-and-exit/split-text-reveal/index.html
+++ b/animations/02-entrance-and-exit/split-text-reveal/index.html
@@ -194,8 +194,8 @@
vars.setProperty('--stagger',stag()+'ms');
vars.setProperty('--ease',ease);
}
- // Rebuilds the split pieces from the current mode and text. Runs immediately when Split into or
- // Your text changes (so the stage never shows a stale split), and again on every play.
+ // Rebuilds the split pieces, hidden, from the current mode and text. Runs at the start of every play,
+ // and at once when Split into or Your text changes so the stage never shows a stale split.
function split(){
target.classList.remove('in');
const text=txtIn.value||'Design beyond the obvious';
@@ -225,10 +225,8 @@
function later(fn,wait){timers.push(setTimeout(fn,wait))}
function playLen(){return target.querySelectorAll('.unit').length*stag()+dur()}
function revealIn(){
- // snap back to hidden without a transition so every play reveals the pieces again
- target.style.setProperty('transition','none','important');
- target.classList.remove('in');void target.offsetWidth;
- target.style.removeProperty('transition');
+ // rebuild the pieces hidden, then show them after a reflow, so every play reveals them from the start
+ split();void target.offsetWidth;
target.classList.add('in');
}
// One play reveals the pieces. While Loop is on it then holds, hides them again, waits and plays
diff --git a/animations/02-entrance-and-exit/word-by-word-reveal/index.html b/animations/02-entrance-and-exit/word-by-word-reveal/index.html
index 4388a4f6..f0991a2c 100644
--- a/animations/02-entrance-and-exit/word-by-word-reveal/index.html
+++ b/animations/02-entrance-and-exit/word-by-word-reveal/index.html
@@ -183,12 +183,13 @@ Software made with care.</textarea>
vars.setProperty('--stagger',stag()+'ms');
vars.setProperty('--ease',ease);
}
- // Rebuilds the words (and the sentence breaks) from the current text, stagger and sentence-pause
- // choice. Runs immediately when Delay between words, Pauses between sentences or Your text changes,
- // so the stage never shows a stale split, and again whenever a play clears the words back to hidden.
+ // Rebuilds the words (and the sentence breaks), hidden, from the current text, stagger and sentence-pause
+ // choice. Runs at the start of every play, and at once when Delay between words, Pauses between sentences
+ // or Your text changes so the stage never shows a stale split.
// --i is stored as delay/stagger using the plain (unmultiplied) stagger value, so slow motion — which
// only stretches the CSS --stagger — scales the sentence-pause bonus along with the per-word delay.
function buildWords(){
+ target.classList.remove('in');
target.innerHTML='';target.dataset.anim=anim;
const sentences=(txtIn.value||'').split('\n').filter(Boolean);
let idx=0;
@@ -213,10 +214,8 @@ Software made with care.</textarea>
return maxIdx*stag()+dur();
}
function revealIn(){
- // snap back to hidden without a transition so every play reveals the words again
- target.style.setProperty('transition','none','important');
- target.classList.remove('in');void target.offsetWidth;
- target.style.removeProperty('transition');
+ // rebuild the words hidden, then show them after a reflow, so every play reveals them from the start
+ buildWords();void target.offsetWidth;
target.classList.add('in');
}
// One play reveals the words in turn. While Loop is on it then holds, hides them again, waits and