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: let screen readers read the words once on Typewriter, Wavy and Scramble

matinc78f109f4a1d
diff --git a/animations/05-text-typography/scramble-text/index.html b/animations/05-text-typography/scramble-text/index.html
index 9aac7d02..8675ad16 100644
--- a/animations/05-text-typography/scramble-text/index.html
+++ b/animations/05-text-typography/scramble-text/index.html
@@ -53,7 +53,7 @@
<div><h2 id="hb-watch-title">Watch it</h2><p>It plays by itself. Turn on slow motion to see each part of the movement.</p></div>
</div>
<div class="stage hb-dots hb-grow">
- <div class="scramble-text" id="scramble-out" aria-label="Scrambling text"></div>
+ <div class="scramble-text" id="scramble-out" role="img" aria-label="Scrambling text"></div>
</div>
<div class="hb-player">
<button class="hb-play" type="button" id="btn-play" data-hb-replay><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>Replay</button>
@@ -179,6 +179,7 @@
text.split(' ').filter(Boolean).forEach((word,wi,words)=>{
const w=document.createElement('span');
w.className='unit-word';
+ w.setAttribute('aria-hidden','true'); // the letters flicker; the container's aria-label carries the words
[...word].forEach(c=>{
const s=document.createElement('span');
s.className=reduce?'char locked':'char scrambling';
diff --git a/animations/05-text-typography/typewriter-effect/index.html b/animations/05-text-typography/typewriter-effect/index.html
index 0fb73c66..e4645d7b 100644
--- a/animations/05-text-typography/typewriter-effect/index.html
+++ b/animations/05-text-typography/typewriter-effect/index.html
@@ -56,10 +56,10 @@
<div><h2 id="hb-watch-title">Watch it</h2><p>It plays by itself. Turn on slow motion to see each part of the movement.</p></div>
</div>
<div class="stage hb-dots hb-grow">
- <div class="type-wrap">
+ <div class="type-wrap" id="type-wrap" role="img">
<div class="type-text type-ghost" id="type-ghost-full" aria-hidden="true"></div>
<div class="type-text type-ghost" id="type-ghost-retyped" aria-hidden="true"></div>
- <div class="type-text" id="type-out" aria-live="polite"></div>
+ <div class="type-text" id="type-out" aria-hidden="true"></div>
</div>
</div>
<div class="hb-player">
@@ -164,7 +164,7 @@
</main>
<footer class="hb-foot"><span>Animation Handbook</span><a href="#top">Back to top ↑</a></footer>
<script>
- const typeOut=document.getElementById('type-out');
+ const typeWrap=document.getElementById('type-wrap'),typeOut=document.getElementById('type-out');
const ghostFull=document.getElementById('type-ghost-full'),ghostRetyped=document.getElementById('type-ghost-retyped');
const vars=document.documentElement.style;
const loopTog=document.getElementById('loop-tog'),slowTog=document.getElementById('slow-tog');
@@ -203,9 +203,13 @@
// Reserves the stage's height for the tallest text this play could show, so nothing moves while it
// types: an invisible copy of the finished text, and, when Deletes and retypes is on, of the retyped
// ending too (deleting and retyping always ends up back at the full text, plus " — always.").
+ // The typed text changes with every keystroke, so it is hidden from screen readers; the wrapper is one image
+ // labelled with the finished text instead, which they read once.
function syncGhosts(text){
+ const retyped=text+' — always.';
ghostFull.textContent=text;
- ghostRetyped.textContent=retypeTog.checked?text+' — always.':'';
+ ghostRetyped.textContent=retypeTog.checked?retyped:'';
+ typeWrap.setAttribute('aria-label',retypeTog.checked?retyped:text);
}
function typeChars(text,done){
diff --git a/animations/05-text-typography/wavy-text/index.html b/animations/05-text-typography/wavy-text/index.html
index 6a2a49b2..9c274e69 100644
--- a/animations/05-text-typography/wavy-text/index.html
+++ b/animations/05-text-typography/wavy-text/index.html
@@ -56,7 +56,7 @@
<div><h2 id="hb-watch-title">Watch it</h2><p>It moves by itself. Pause it to look closely, or turn on slow motion to see each part of the movement.</p></div>
</div>
<div class="stage" id="stage">
- <div class="wave-text" id="wave" aria-label="Wavy">Wavy</div>
+ <div class="wave-text" id="wave" role="img" aria-label="Wavy">Wavy</div>
</div>
<div class="hb-player">
<button class="hb-play" type="button" id="btn-pause" data-hb-pause="css" data-state="playing"><svg class="hb-ic hb-i-pause" viewBox="0 0 24 24" aria-hidden="true"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg><svg class="hb-ic hb-i-play" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3l14 9-14 9z"/></svg><span class="hb-pause-label">Pause</span></button>