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.

feat: move Kinetic Typography to the guided-steps page

matinc50580321937
diff --git a/animations/05-text-typography/kinetic-typography/README.md b/animations/05-text-typography/kinetic-typography/README.md
index ba352001..1a691ca4 100644
--- a/animations/05-text-typography/kinetic-typography/README.md
+++ b/animations/05-text-typography/kinetic-typography/README.md
@@ -1,7 +1,7 @@
# Kinetic Typography
## What it is
-Kinetic typography is the practice of animating text so that its motion reinforces its meaning. Rather than animating text as a generic UI element, each word or phrase is choreographed — scale, trajectory, timing, and rhythm are all chosen to serve the specific copy. It originates from motion graphics and broadcast design but has migrated to web via CSS animations and canvas-based tools.
+Kinetic typography is text in motion, where the way each word moves matches what it means. A short sequence shows one phrase at a time, and each phrase gets its own way in and out: a heavy word can drop in large, a soft word can simply fade. It comes from film titles and motion graphics, where moving words tell a story on their own.
## When to use it
- Opening sequences and splash screens where brand personality is established
@@ -27,10 +27,10 @@ function showPhrase(i) {
function run(idx = 0) {
showPhrase(idx);
+ const last = idx === PHRASES.length - 1;
+ if (last && !loop) return; // the final phrase stays on screen
setTimeout(() => {
- exitPhrase(idx, () => {
- if (idx + 1 < PHRASES.length) run(idx + 1);
- });
+ exitPhrase(idx, () => run((idx + 1) % PHRASES.length));
}, ENTER_DUR + PHRASES[idx].hold);
}
```
@@ -45,19 +45,16 @@ Each enter and exit is a standalone `@keyframes` rule:
@keyframes kExitUp { from { opacity:1; transform:translateY(0) } to { opacity:0; transform:translateY(-50px) } }
```
-Playback speed is controlled via a CSS custom property used in every `calc()`:
+The Speed setting is a CSS custom property used in every `calc()`; the timers divide by the same value:
```css
.enter-scale { animation-duration: calc(600ms / var(--spd)); }
```
## Key parameters
-| Parameter | Typical range | Effect |
-|-----------|--------------|--------|
-| Enter duration | 400–800ms | Fast entries feel punchy; slow entries feel deliberate |
-| Hold duration | 1000–2500ms | Must be long enough to read the phrase; subtitle reading speed is ~200ms/word |
-| Exit duration | 300–500ms | Exits are usually shorter than entries — departure is less important than arrival |
-| Playback speed | 0.5×–2× | Multiply all durations by inverse of speed factor |
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Speed | Normal | The pace of the whole sequence: slow plays it at 0.6× speed, normal at 1× and fast at 1.7×; entrances, holds and exits all scale together |
## Production notes
- **Copy-first choreography**: the motion should be chosen for the words, not the other way around. Soft/gentle words dissolve; heavy words slam in; fragile words flutter. Generic enters and exits applied uniformly undermine the whole technique.
@@ -67,6 +64,6 @@ Playback speed is controlled via a CSS custom property used in every `calc()`:
- **`prefers-reduced-motion`**: show all phrases simultaneously or show only the final phrase — don't suppress the text itself.
## See also
-- [Enter/Exit Typography](../enter-exit-typography/) — the same enter→hold→exit pattern focused on prose storytelling
-- [Rotate Word Carousel](../rotate-word-carousel/) — a single cycling word rather than full phrase sequences
-- [Text Clip-Path Reveal](../text-clip-path-reveal/) — one of the enter techniques used here as a standalone pattern
+- [Enter/Exit Typography](../enter-exit-typography/) — each phrase comes in, holds and leaves
+- [Rotate Word Carousel](../rotate-word-carousel/) — one word in a sentence keeps changing
+- [Text Clip-Path Reveal](../text-clip-path-reveal/) — lines of text are uncovered one by one
diff --git a/animations/05-text-typography/kinetic-typography/index.html b/animations/05-text-typography/kinetic-typography/index.html
index cd584b56..97804e7e 100644
--- a/animations/05-text-typography/kinetic-typography/index.html
+++ b/animations/05-text-typography/kinetic-typography/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kinetic Typography — Animation Handbook</title>
- <meta name="description" content="Text in motion — phrases enter, transform, and exit in a coordinated timeline.">
+ <meta name="description" content="Words arrive and leave one by one, each moving its own way. Best for intros.">
<link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/kinetic-typography/">
<link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png">
<link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
@@ -12,33 +12,21 @@
<meta property="og:type" content="article">
<meta property="og:site_name" content="Animation Handbook">
<meta property="og:title" content="Kinetic Typography — Animation Handbook">
- <meta property="og:description" content="Text in motion — phrases enter, transform, and exit in a coordinated timeline.">
+ <meta property="og:description" content="Words arrive and leave one by one, each moving its own way. Best for intros.">
<meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/kinetic-typography/">
<meta property="og:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Kinetic Typography — Animation Handbook">
- <meta name="twitter:description" content="Text in motion — phrases enter, transform, and exit in a coordinated timeline.">
+ <meta name="twitter:description" content="Words arrive and leave one by one, each moving its own way. Best for intros.">
<meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
- <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Kinetic Typography", "name": "Kinetic Typography", "description": "Text in motion — phrases enter, transform, and exit in a coordinated timeline.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/kinetic-typography/", "inLanguage": "en", "articleSection": "Text & Typography", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Text & Typography, Kinetic Typography"}</script>
+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Kinetic Typography", "name": "Kinetic Typography", "description": "Words arrive and leave one by one, each moving its own way. Best for intros.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/kinetic-typography/", "inLanguage": "en", "articleSection": "Text & Typography", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Text & Typography, Kinetic Typography"}</script>
<style>
- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-700.woff2') format('woff2');font-weight:700;font-display:swap}
- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-800.woff2') format('woff2');font-weight:800;font-display:swap}
- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-400.woff2') format('woff2');font-weight:400;font-display:swap}
- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-500.woff2') format('woff2');font-weight:500;font-display:swap}
- :root{--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#ff6f8b;--ui-text:#f4f4f2;--ui-muted:#77777e;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace;--stage-h:620px;--spd:1}
+ :root{--ui-accent:#ff6f8b;--spd:1}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
- body{background:var(--bg);color:var(--ui-text);font-family:var(--mono);-webkit-font-smoothing:antialiased;padding:clamp(12px,3vw,24px)}
- header{margin-bottom:20px}
- header h1{font-family:var(--disp);font-weight:700;font-size:clamp(16px,2.2vw,22px);letter-spacing:-.01em}
- header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
- .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
- .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;background:#04060c;overflow:hidden;position:relative;display:flex;align-items:center;justify-content:center}
- /* Phrase display */
+ .stage{display:flex;align-items:center;justify-content:center;background:#04060c;position:relative}
#phrase{position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;padding:32px;text-align:center}
- .kw{font-family:Georgia,'Times New Roman',serif;font-size:clamp(40px,8vw,90px);line-height:1;letter-spacing:-0.02em;color:#fff;will-change:transform,opacity;display:block}
- .kw.sub{font-family:monospace;font-size:clamp(11px,1.5vw,14px);letter-spacing:4px;text-transform:uppercase;color:var(--ui-muted);margin-top:12px}
- /* Enter/exit animations */
- .kw{opacity:0;transform:translateY(0) scale(1)}
+ .kw{font-size:clamp(40px,8vw,90px);line-height:1;letter-spacing:-0.02em;color:#fff;font-weight:800;opacity:0;transform:translateY(0) scale(1);will-change:transform,opacity;display:block}
+ .kw.sub{font-size:clamp(11px,1.5vw,14px);font-weight:600;letter-spacing:4px;text-transform:uppercase;color:#8a8a92;margin-top:12px}
.enter-scale{animation:kEnterScale calc(600ms / var(--spd)) ease-out forwards}
.enter-slide{animation:kEnterSlide calc(500ms / var(--spd)) ease-out forwards}
.enter-fade{animation:kEnterFade calc(400ms / var(--spd)) ease-out forwards}
@@ -57,144 +45,161 @@
@keyframes kExitFade{from{opacity:1}to{opacity:0}}
@keyframes kExitShrink{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.3)}}
@keyframes kExitRight{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(80px)}}
- /* Beat markers */
- .beat-bar{position:absolute;bottom:0;left:0;right:0;height:3px;background:var(--ui-border)}
- .beat-fill{height:100%;background:var(--ui-accent);transform-origin:left;transform:scaleX(0);transition:transform 100ms linear}
- /* Phrase counter */
- .phrase-counter{position:absolute;top:14px;right:14px;font-size:10px;color:var(--ui-muted);letter-spacing:1px}
- /* Panel */
- aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
- .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
- .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
- .kv{display:flex;justify-content:space-between;font-size:10px;color:var(--ui-muted)}
- .kv .v{color:var(--ui-text)}
- .div{height:1px;background:var(--ui-border)}
- .sr{display:flex;align-items:center;gap:6px;font-size:10px}
- .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
- .sv{width:36px;text-align:right;color:var(--ui-text)}
- .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
- .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
- button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:var(--mono);font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
- @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
- @media(max-width:600px){.layout{flex-direction:column;align-items:stretch}aside{width:100%}:root{--stage-h:420px}.stage{flex:none}}
- @media(prefers-reduced-motion:reduce){.kw{animation:none!important;opacity:1!important;transform:none!important;clip-path:none!important}.beat-fill{transition:none}}
+ @media(prefers-reduced-motion:reduce){.kw{animation:none!important;opacity:1!important;transform:none!important;clip-path:none!important}}
</style>
-<style id="ah-inject">
-:root{--ah-bg:rgba(17,17,20,.82);--ah-line:rgba(255,255,255,.1);--ah-ink:#f4f4f2;--ah-muted:#9a9aa2;--ah-accent:#6ea8ff}
-body{padding-top:46px}
-.ah-bar{position:fixed;top:0;left:0;right:0;height:46px;z-index:2147483000;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:0 clamp(10px,3vw,18px);background:var(--ah-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid var(--ah-line);font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;box-sizing:border-box}
-.ah-bar a,.ah-bar button{color:var(--ah-muted);text-decoration:none;background:none;border:0;font:inherit;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 7px;border-radius:6px;transition:color .18s,background .18s;white-space:nowrap}
-.ah-bar a:hover,.ah-bar button:hover{color:var(--ah-ink)}
-.ah-home{color:var(--ah-ink);font-weight:600}
-.ah-actions{display:flex;align-items:center;gap:2px}
-.ah-sep{width:1px;height:16px;background:var(--ah-line);margin:0 4px}
-.ah-copied{color:var(--ah-accent)!important}
-@media(max-width:600px){.ah-bar .ah-hideSm{display:none}}
-@media print{.ah-bar{display:none}body{padding-top:0}}
-</style>
+ <link rel="stylesheet" href="../../../assets/css/demo-page.css?v=3">
+ <script src="../../../assets/js/demo-page.js?v=3" defer></script>
</head>
-<body>
-<div class="ah-bar" role="navigation" aria-label="Animation Handbook"><a class="ah-home" href="../../../">← Animation Handbook</a><span class="ah-actions"><a class="ah-hideSm" href="../typewriter-effect/" rel="next" title="Next">Next ›</a><span class="ah-sep ah-hideSm"></span><button type="button" id="ah-copy" class="ah-hideSm">Copy source</button><a class="ah-hideSm" href="https://github.com/matinmonshizadeh/animation-handbook/blob/main/animations/05-text-typography/kinetic-typography/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>
-<header>
- <h1>Kinetic Typography</h1>
- <p>Text in motion — phrases enter, transform, and exit in a coordinated timeline.</p>
-</header>
-<div class="layout">
- <div class="stage">
- <div id="phrase" aria-live="polite"></div>
- <div class="phrase-counter" id="counter">1 / 6</div>
- <div class="beat-bar"><div class="beat-fill" id="beat-fill"></div></div>
- </div>
- <aside>
- <p class="note">Kinetic typography is choreography for words. Each transform should reinforce the meaning — a soft word dissolves; a hard word snaps in.</p>
- <div class="lbl">Playback Speed</div>
- <div class="sr"><input type="range" id="spd-sl" min="5" max="20" value="10" step="1"><span class="sv" id="spd-v">1.0×</span></div>
- <div class="div"></div>
- <div class="kv"><span>Phrase</span><span class="v" id="phrase-kv">1 / 6</span></div>
- <div class="kv"><span>State</span><span class="v" id="state-kv">Playing</span></div>
- <div class="div"></div>
- <button class="rst" id="play-btn">▶ Play / Restart</button>
- <label class="tog"><input type="checkbox" id="loop-tog"><span>Loop sequence</span></label>
- <label class="tog"><input type="checkbox" id="beat-tog" checked><span>Show progress bar</span></label>
- </aside>
-</div>
+<body class="hb" data-hb-kind="once" data-hb-autoplay>
+<nav class="hb-bar" aria-label="Animation Handbook">
+ <a class="hb-home" href="../../../"><svg class="hb-mark" viewBox="0 0 32 32" aria-hidden="true"><g class="g"><circle cx="11.16" cy="20.84" r="6.1"/><circle cx="15.12" cy="16.88" r="6.1"/><circle cx="18.51" cy="13.49" r="6.1"/></g><circle class="b" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>
+ <span class="hb-pager"><a href="../typewriter-effect/" rel="next" aria-label="Next: Typewriter Effect"><span><span class="hb-dir">Next: </span>Typewriter Effect</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a></span>
+</nav>
+<main class="hb-page">
+ <header class="hb-head">
+ <p class="hb-cat">05.01 · Text &amp; Typography</p>
+ <h1>Kinetic Typography</h1>
+ <p class="hb-lede">Words arrive and leave one by one, each moving its own way. Best for intros.</p>
+ </header>
+
+ <section class="hb-step hb-watch" aria-labelledby="hb-watch-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">1</span>
+ <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">
+ <div id="phrase" aria-live="polite"></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>
+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="loop-tog" data-hb-loop autocomplete="off"><span>Loop</span></label>
+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="slow-tog" data-hb-slowmo autocomplete="off"><span>Slow motion</span></label>
+ </div>
+ </section>
+
+ <section class="hb-step hb-try" aria-labelledby="hb-try-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">2</span>
+ <div><h2 id="hb-try-title">Try it</h2><p>Change a setting and the animation plays again.</p></div>
+ </div>
+ <div class="hb-settings">
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="speed-lbl">Speed</p>
+ <div class="seg" id="speed-seg" role="group" aria-labelledby="speed-lbl">
+ <button type="button" data-speed="0.6" aria-pressed="false">Slow</button>
+ <button type="button" data-speed="1" class="on" aria-pressed="true">Normal</button>
+ <button type="button" data-speed="1.7" aria-pressed="false">Fast</button>
+ </div>
+ <p class="hb-hint">Changes the pace of the whole sequence.</p>
+ </div>
+ </div>
+ </section>
+
+ <section class="hb-step hb-prompt-step" aria-labelledby="hb-prompt-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">3</span>
+ <div><h2 id="hb-prompt-title">Copy the prompt</h2><p>Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.</p></div>
+ </div>
+ <div class="hb-card">
+ <p class="hb-prompt">Add a kinetic typography sequence to [the short phrases you want to show]. Show one phrase at a time and give each an entrance and an exit that fit its meaning: a heavy word can drop in large, a soft word can simply fade, a quick word can slide. Hold each phrase long enough to be read, and use size and color so the key words stand out. Leave the final phrase on screen when the sequence ends. Screen readers should hear each phrase as plain text. If the visitor has reduced motion turned on, show the phrases without movement. Match the settings listed below.</p>
+ <div class="hb-chips-box" hidden>
+ <p class="hb-chips-title">Your settings</p>
+ <ul class="hb-chips"></ul>
+ </div>
+ <div class="hb-copy-row">
+ <button class="hb-copy" type="button"><svg class="hb-ic hb-i-copy" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg><svg class="hb-ic hb-i-done" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg><span class="hb-copy-label" aria-live="polite">Copy prompt</span></button>
+ <p class="hb-hint">Replace the words in brackets with your own element. Your settings are added at the end.</p>
+ </div>
+ </div>
+ </section>
+
+ <section class="hb-about" aria-labelledby="hb-what-title">
+ <div class="hb-what">
+ <h2 id="hb-what-title">What it is</h2>
+ <div class="hb-what-text"><p>The full explanation is in <a href="README.md">README.md</a>.</p></div>
+ </div>
+ <div class="hb-fit">
+ <h2>Good for</h2>
+ <ul class="hb-tags hb-good"><li>Intros</li><li>Splash screens</li><li>Story sections</li><li>Presentations</li></ul>
+ <h3>Avoid on</h3>
+ <ul class="hb-tags hb-avoid"><li>Forms and menus</li><li>Long text</li></ul>
+ </div>
+ </section>
+
+ <section class="hb-related" aria-labelledby="hb-related-title" hidden>
+ <h2 id="hb-related-title">Similar animations</h2>
+ <div class="hb-rel-list"></div>
+ </section>
+</main>
+<footer class="hb-foot"><span>Animation Handbook</span><a href="#top">Back to top ↑</a></footer>
<script>
-const PHRASES=[
- {text:'EVERY',sub:'word has',enter:'enter-scale',exit:'exit-up',hold:1400,color:'#c9d1d9'},
- {text:'A WEIGHT',sub:null,enter:'enter-slide',exit:'exit-right',hold:1600,color:'#58a6ff'},
- {text:'AND',sub:null,enter:'enter-fade',exit:'exit-fade',hold:900,color:'#8b949e'},
- {text:'A MOMENT',sub:null,enter:'enter-big',exit:'exit-shrink',hold:1800,color:'#d2a8ff'},
- {text:'IN MOTION',sub:'it becomes',enter:'enter-clip',exit:'exit-up',hold:1600,color:'#56d364'},
- {text:'MEANING.',sub:null,enter:'enter-scale',exit:'exit-fade',hold:2200,color:'#ffa657'},
-];
-let idx=0,timer=null,running=false,speed=1;
-const phraseEl=document.getElementById('phrase');
-const counterEl=document.getElementById('counter');
-const phraseKv=document.getElementById('phrase-kv');
-const stateKv=document.getElementById('state-kv');
-const beatFill=document.getElementById('beat-fill');
+ const phraseEl=document.getElementById('phrase');
+ const vars=document.documentElement.style;
+ const loopTog=document.getElementById('loop-tog'),slowTog=document.getElementById('slow-tog');
+ const motionOk=!window.matchMedia('(prefers-reduced-motion:reduce)').matches;
+ let speed=1,timers=[];
-function ms(n){return Math.round(n/speed)}
+ const PHRASES=[
+ {text:'EVERY',sub:'word has',enter:'enter-scale',exit:'exit-up',hold:1400,color:'#c9d1d9'},
+ {text:'A WEIGHT',sub:null,enter:'enter-slide',exit:'exit-right',hold:1600,color:'#58a6ff'},
+ {text:'AND',sub:null,enter:'enter-fade',exit:'exit-fade',hold:900,color:'#8b949e'},
+ {text:'A MOMENT',sub:null,enter:'enter-big',exit:'exit-shrink',hold:1800,color:'#d2a8ff'},
+ {text:'IN MOTION',sub:'it becomes',enter:'enter-clip',exit:'exit-up',hold:1600,color:'#56d364'},
+ {text:'MEANING.',sub:null,enter:'enter-scale',exit:'exit-fade',hold:2200,color:'#ffa657'},
+ ];
-function showPhrase(i){
- const p=PHRASES[i];
- phraseEl.innerHTML='';
- const w=document.createElement('span');w.className='kw';
- w.style.color=p.color;w.textContent=p.text;phraseEl.appendChild(w);
- if(p.sub){const s=document.createElement('span');s.className='kw sub';s.textContent=p.sub;phraseEl.appendChild(s);}
- counterEl.textContent=(i+1)+' / '+PHRASES.length;
- phraseKv.textContent=(i+1)+' / '+PHRASES.length;
- beatFill.style.transform='scaleX('+((i+1)/PHRASES.length)+')';
- requestAnimationFrame(()=>{
- w.classList.add(p.enter);
- if(p.sub)phraseEl.querySelectorAll('.sub').forEach(s=>{s.style.animationDelay='200ms';s.classList.add(p.enter);});
- });
-}
+ function slowFactor(){return slowTog.checked?3:1}
+ function ms(n){return Math.round(n/speed)}
+ function apply(){vars.setProperty('--spd',String(slowTog.checked?speed/3:speed))}
+ function later(fn,wait){timers.push(setTimeout(fn,wait))}
-function exitPhrase(i,done){
- const p=PHRASES[i];
- phraseEl.querySelectorAll('.kw').forEach(w=>{
- w.style.animationDelay='';w.classList.remove(p.enter);w.classList.add(p.exit);
- });
- // Every pending timeout in the chain is stored in `timer` so Play/Restart can cancel it.
- timer=setTimeout(done,ms(520));
-}
+ // Rebuilds the phrase hidden (word, then its sub-line if it has one), forces a reflow, then starts the
+ // word's own entrance; the sub-line starts its entrance 200ms later (scaled by slow motion and Speed).
+ function showPhrase(i){
+ const p=PHRASES[i];
+ phraseEl.innerHTML='';
+ const w=document.createElement('span');
+ w.className='kw';w.style.color=p.color;w.textContent=p.text;
+ phraseEl.appendChild(w);
+ let s=null;
+ if(p.sub){s=document.createElement('span');s.className='kw sub';s.textContent=p.sub;phraseEl.appendChild(s);}
+ void phraseEl.offsetWidth;
+ w.classList.add(p.enter);
+ if(s)later(()=>s.classList.add(p.enter),ms(200*slowFactor()));
+ }
+ function exitPhrase(i,done){
+ const p=PHRASES[i];
+ phraseEl.querySelectorAll('.kw').forEach(w=>{w.classList.remove(p.enter);w.classList.add(p.exit)});
+ later(done,ms(520*slowFactor()));
+ }
-function run(){
- if(running)return;running=true;stateKv.textContent='Playing';
- idx=0;
- function step(){
- showPhrase(idx);
- const hold=PHRASES[idx].hold;
- timer=setTimeout(()=>{
- exitPhrase(idx,()=>{
- idx++;
- if(idx<PHRASES.length){timer=setTimeout(step,ms(120));}
- else{
- running=false;stateKv.textContent='Done';
- if(document.getElementById('loop-tog').checked){beatFill.style.transform='scaleX(0)';timer=setTimeout(run,ms(800));}
- }
+ // Plays phrase i: enter, hold, exit, then the next phrase 120ms later. The last phrase stays on screen
+ // after its hold; while Loop is on it exits too, the stage waits 800ms and the play restarts.
+ function step(i){
+ apply();
+ showPhrase(i);
+ later(()=>{
+ const last=i===PHRASES.length-1;
+ if(last&&(!loopTog.checked||!motionOk))return;
+ exitPhrase(i,()=>{
+ if(last)later(()=>step(0),ms(800));
+ else later(()=>step(i+1),ms(120));
});
- },ms(500+hold));
+ },ms(500*slowFactor()+PHRASES[i].hold));
}
- step();
-}
+ function play(){timers.forEach(clearTimeout);timers=[];step(0)}
-document.getElementById('play-btn').addEventListener('click',()=>{
- clearTimeout(timer);running=false;beatFill.style.transform='scaleX(0)';
- timer=setTimeout(run,50);
-});
-document.getElementById('spd-sl').addEventListener('input',e=>{
- speed=e.target.value/10;
- document.getElementById('spd-v').textContent=speed.toFixed(1)+'×';
- document.documentElement.style.setProperty('--spd',speed);
-});
-document.getElementById('beat-tog').addEventListener('change',e=>{
- beatFill.parentElement.style.display=e.target.checked?'block':'none';
-});
-
-run();
+ document.getElementById('btn-play').addEventListener('click',play);
+ loopTog.addEventListener('change',()=>{if(loopTog.checked)play()});
+ function choices(id,pick){
+ const buttons=document.querySelectorAll('#'+id+' button');
+ buttons.forEach(b=>b.addEventListener('click',()=>{
+ buttons.forEach(x=>{x.classList.toggle('on',x===b);x.setAttribute('aria-pressed',String(x===b))});
+ pick(b.dataset);
+ }));
+ }
+ choices('speed-seg',d=>{speed=+d.speed});
+ apply();
</script>
-<script>(function(){var b=document.getElementById("ah-copy");if(!b)return;b.addEventListener("click",function(){fetch(location.href).then(function(r){return r.text();}).catch(function(){return document.documentElement.outerHTML;}).then(function(t){return navigator.clipboard.writeText(t);}).then(function(){b.textContent="Copied!";b.classList.add("ah-copied");setTimeout(function(){b.textContent="Copy source";b.classList.remove("ah-copied");},1500);}).catch(function(){b.textContent="Copy failed";setTimeout(function(){b.textContent="Copy source";},1500);});});})();</script>
</body>
</html>
diff --git a/index.html b/index.html
index 0037b808..9d344cb1 100644
--- a/index.html
+++ b/index.html
@@ -987,7 +987,7 @@ const CATS=[
desc:'Animations specifically for type — kinetic motion, character-level effects, gradient flows, and word transformations.',
folder:'animations/05-text-typography',
entries:[
- ['kinetic-typography','Kinetic Typography','Phrases enter, transform, and exit in a choreographed timeline — motion reinforces meaning.'],
+ ['kinetic-typography','Kinetic Typography','Words arrive and leave one by one, each moving its own way. Best for intros.'],
['typewriter-effect','Typewriter Effect','Characters appear one at a time with a blinking cursor — natural timing variance makes it feel human.'],
['scramble-text','Scramble / Glitch Text','Characters cycle randomly before locking left-to-right — decryption and sci-fi aesthetic.'],
['variable-font-morph','Variable Font Morph','CSS font-variation-settings animates weight, slant, and casual axes of a variable font.'],