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.

test: the keyboard test checks each pointer page's real keyboard path (arrow keys, focus styled like Show me, or a keyboard click), and review fixes: Spotlight's label names the arrow keys, Hover State's sample shows its focus state, American spelling in Magnetic Button

matind9445c1854e0
diff --git a/animations/04-micro-interactions/hover-state/README.md b/animations/04-micro-interactions/hover-state/README.md
index c7636ecf..78bad824 100644
--- a/animations/04-micro-interactions/hover-state/README.md
+++ b/animations/04-micro-interactions/hover-state/README.md
@@ -20,12 +20,12 @@ All six techniques use CSS `transition` driven by `:hover` (or `:active` as a to
/* Color shift */
.h-color { transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
@media (hover: hover) { .h-color:hover { background: #2a201a; border-color: var(--ui-accent); } }
-.h-color:active { background: #2a201a; border-color: var(--ui-accent); }
+.h-color:active, .h-color:focus-visible { background: #2a201a; border-color: var(--ui-accent); }
/* Scale */
.h-scale { transition: transform var(--dur) var(--ease); }
@media (hover: hover) { .h-scale:hover { transform: scale(1.03); } }
-.h-scale:active { transform: scale(1.03); }
+.h-scale:active, .h-scale:focus-visible { transform: scale(1.03); }
/* Background sweep */
.h-sweep::before {
diff --git a/animations/04-micro-interactions/magnetic-button/index.html b/animations/04-micro-interactions/magnetic-button/index.html
index 33d0af07..5ca85fe0 100644
--- a/animations/04-micro-interactions/magnetic-button/index.html
+++ b/animations/04-micro-interactions/magnetic-button/index.html
@@ -139,7 +139,7 @@
const s=stage.getBoundingClientRect(),b=btn.getBoundingClientRect();
const dx=px-(b.left+b.width/2-s.left),dy=py-(b.top+b.height/2-s.top),dist=Math.hypot(dx,dy);
if(dist<radius){
- const f=1-dist/radius; // full strength at the button's centre, easing to none at the edge of Reach
+ const f=1-dist/radius; // full strength at the button's center, easing to none at the edge of Reach
const tx=dx*strength*f,ty=dy*strength*f;
btn.style.setProperty('--tx',tx+'px');btn.style.setProperty('--ty',ty+'px');
label.style.transform=`translate(${tx*0.35}px,${ty*0.35}px)`;
@@ -215,7 +215,7 @@
btn.addEventListener('keyup',e=>{if(e.key===' '||e.key==='Enter')btn.classList.remove('pressed')});
// A pretend pointer visits three spots around the button: each glide takes 550ms and each spot is held 150ms, then the button goes home.
- // The spots are fixed offsets from the button's resting centre, read from its layout box (the pull's transform never moves it) in the
+ // The spots are fixed offsets from the button's resting center, read from its layout box (the pull's transform never moves it) in the
// pull's own frame, the stage's border box, and sized by Reach so they always fall within it.
const SPOTS=[[-.55,-.35],[.6,.1],[-.1,.5]];
document.getElementById('btn-demo').addEventListener('click',()=>{
diff --git a/animations/04-micro-interactions/spotlight-hover/index.html b/animations/04-micro-interactions/spotlight-hover/index.html
index 765e1bd4..fd704981 100644
--- a/animations/04-micro-interactions/spotlight-hover/index.html
+++ b/animations/04-micro-interactions/spotlight-hover/index.html
@@ -72,7 +72,7 @@
<div><h2 id="hb-watch-title">Hover it</h2><p>Move your pointer over the cards, drag a finger across them (or Tab to them and use the arrow keys), or press Show me.</p></div>
</div>
<div class="stage">
- <div class="grid" id="grid" tabindex="0" role="group" aria-label="Feature cards">
+ <div class="grid" id="grid" tabindex="0" role="group" aria-label="Feature cards: use the arrow keys to move the light">
<div class="sc"><span class="eg" aria-hidden="true"></span><div class="face"><span class="fg" aria-hidden="true"></span><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3v18h18"/><path d="m7 15 4-4 3 3 5-6"/></svg><p class="t">Analytics</p><p class="d">See what people click.</p></div></div>
<div class="sc"><span class="eg" aria-hidden="true"></span><div class="face"><span class="fg" aria-hidden="true"></span><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M13 2 4 14h7l-1 8 9-12h-7z"/></svg><p class="t">Automations</p><p class="d">Runs tasks for you.</p></div></div>
<div class="sc"><span class="eg" aria-hidden="true"></span><div class="face"><span class="fg" aria-hidden="true"></span><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3 20 6v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"/></svg><p class="t">Security</p><p class="d">Logins kept safe.</p></div></div>
diff --git a/tests/pages.test.js b/tests/pages.test.js
index e635bf14..b2793980 100644
--- a/tests/pages.test.js
+++ b/tests/pages.test.js
@@ -314,9 +314,14 @@ test('the do-it pages played with the pointer can be played from the keyboard',
const script = [...html.matchAll(/<script>([\s\S]*?)<\/script>/g)].map(m => m[1]).join('\n');
if (!stage) problems.push(`${cat}/${slug}: no stage found`);
else if (!/<button\b|<a\b[^>]*\shref=|\stabindex="0"/.test(stage)) problems.push(`${cat}/${slug}: nothing in the stage takes keyboard focus`);
- if (!/['"]keydown['"]|\bonkeydown\b/.test(script) && !cssRules(style).some(rule => rule.selector.includes(':focus-visible'))) {
- problems.push(`${cat}/${slug}: the page has no keydown listener and no :focus-visible rule`);
- }
+ // The keyboard does what the pointer does in one of three ways: the arrow keys move a pretend pointer (a keydown
+ // listener that names an arrow key), keyboard focus shows what Show me shows (a :focus-visible selector in a rule
+ // with .is-demo), or a click with no pointer (detail 0: Enter, Space or assistive technology) starts the effect.
+ // A :focus-visible rule that only recolors the focus ring is none of these.
+ const arrows = /['"]keydown['"]/.test(script) && /\bArrow(Left|Right|Up|Down)\b/.test(script);
+ const focusShows = cssRules(style).some(rule => rule.selector.includes(':focus-visible') && rule.selector.includes('.is-demo'));
+ const keyClick = /\.detail\s*[!=]==?\s*0\b/.test(script);
+ if (!arrows && !focusShows && !keyClick) problems.push(`${cat}/${slug}: no keyboard path (arrow keys, focus styled with .is-demo, or a click with detail 0)`);
}
}
assert.deepEqual(problems, []);