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: Split-Flap Board keeps the word field, board and chip in step and reads the flip time once per play
matin6b68657877b0
diff --git a/animations/05-text-typography/split-flap-board/README.md b/animations/05-text-typography/split-flap-board/README.mdindex b57bf677..f64be9bf 100644--- a/animations/05-text-typography/split-flap-board/README.md+++ b/animations/05-text-typography/split-flap-board/README.md@@ -50,7 +50,7 @@ Each tile's run of letters is the drum from a blank to its letter (" ABC…" up- **Exact halves**: the two halves of a letter must meet at the hinge. Use `line-height: 1`, a letter box exactly twice the height of a half, and check the font's capitals: some sit a little high or low and need a small nudge.- **Accessibility**: the row is one image named with the final word, and the tiles are hidden from screen readers, so the word is read once rather than every letter it passes through.- **Sound**: a soft clatter makes the board feel real, but play it only after the visitor has interacted, and give them a way to mute it.-- **Libraries**: GSAP can sequence the `rotationX` tweens per tile; there are also small split-flap web components. CSS-only versions use keyframes with `steps()`, but they cannot stop each tile on its own letter.+- **Libraries**: GSAP can sequence the `rotationX` tweens per tile; there are also small split-flap web components. A CSS-only version works too: give each tile a column of letters and move it with `steps()`, as the card on the handbook's home page does, so each tile stops on its own letter. The catch is that the keyframes and the number of steps have to be generated for every word.## See also- [Scramble / Glitch Text](../scramble-text/) — random symbols lock into the real text, left to rightdiff --git a/animations/05-text-typography/split-flap-board/index.html b/animations/05-text-typography/split-flap-board/index.htmlindex d029729b..3e8a0d14 100644--- a/animations/05-text-typography/split-flap-board/index.html+++ b/animations/05-text-typography/split-flap-board/index.html@@ -160,9 +160,28 @@const loopTog=document.getElementById('loop-tog'),slowTog=document.getElementById('slow-tog');const motionOk=()=>!window.matchMedia('(prefers-reduced-motion:reduce)').matches;const DRUM=' ABCDEFGHIJKLMNOPQRSTUVWXYZ',STAGGER=40; // the letters a tile turns through, in order; each tile starts 40ms after the one on its left- let flipMs=85,tiles=[],raf=0,clock=0,lastT=null,timers=[];+ let ms=85,flipMs=85,tiles=[],raf=0,clock=0,lastT=null,timers=[]; // ms: the setting; flipMs: the flip time of the play under way- function word(){return wordIn.value.toUpperCase().replace(/[^A-Z ]/g,'').trim()||'BOARDING'}+ // The field only ever holds what the board can show (capitals, A to Z, single spaces), so the board, the field and the+ // "Word" chip always agree. Cleaned as the visitor types, before the shared script reads it; the caret stays in place.+ // A phone keyboard that is still composing a word is left alone until it is done.+ const clean=s=>s.toUpperCase().replace(/[^A-Z ]/g,'').replace(/ {2,}/g,' ');+ function tidy(){+ const v=wordIn.value,c=clean(v);+ if(c===v)return false;+ const at=clean(v.slice(0,wordIn.selectionStart)).length;+ wordIn.value=c;wordIn.setSelectionRange(at,at);+ return true;+ }+ wordIn.addEventListener('input',e=>{if(!e.isComposing)tidy()});+ wordIn.addEventListener('compositionend',()=>{if(tidy())wordIn.dispatchEvent(new Event('input',{bubbles:true}))});+ // A field left empty gets the default word back, and the input event updates the chip and plays it again+ wordIn.addEventListener('blur',()=>{+ if(wordIn.value.trim())return;+ wordIn.value='BOARDING';+ wordIn.dispatchEvent(new Event('input',{bubbles:true}));+ });+ function word(){return clean(wordIn.value).trim()||'BOARDING'}// One tile per letter. Each tile keeps its run of letters, from a blank to its own letter, and the flip it is on (k).function build(text){row.textContent='';@@ -213,9 +232,11 @@later(cycle,400);},1800);}- // Every play starts from blank tiles. Under reduced motion the letters fade in instead of flipping.+ // Every play starts from blank tiles. Under reduced motion the letters fade in instead of flipping. The flip time is read+ // here, once per play: a Flip speed pressed mid-run applies from the next play, so no tile jumps or flips again.function cycle(){cancelAnimationFrame(raf);raf=0;+ flipMs=ms;build(word());row.classList.remove('clearing');if(!motionOk()){@@ -238,7 +259,7 @@pick(b.dataset);}));}- choices('speed-seg',d=>{flipMs=+d.ms});+ choices('speed-seg',d=>{ms=+d.ms});choices('color-sw',d=>{vars.setProperty('--tile',d.c);vars.setProperty('--ink',d.ink)});build(word());tiles.forEach(t=>rest(t,' '));</script>