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 Enter/Exit Typography to the guided-steps page

matinef4d5f0278de
diff --git a/animations/05-text-typography/enter-exit-typography/README.md b/animations/05-text-typography/enter-exit-typography/README.md
index 6cd7402b..ce534f86 100644
--- a/animations/05-text-typography/enter-exit-typography/README.md
+++ b/animations/05-text-typography/enter-exit-typography/README.md
@@ -1,7 +1,7 @@
# Enter/Exit Typography
## What it is
-Enter/exit typography treats each phrase as a three-act sequence: it enters the frame, holds long enough to be read, then exits to make way for the next. This is the full lifecycle of on-screen text in broadcast, presentation, and storytelling contexts. The key insight is that the exit is as important as the entry — the direction and character of each phrase's departure creates continuity with the next phrase's arrival.
+Enter/exit typography shows short phrases one at a time in the same place. Each phrase comes in, holds still long enough to be read, then leaves before the next one arrives. Every phrase has its own way in and out, such as sliding, growing, blurring or wiping, and the last one stays on screen when the sequence ends.
## When to use it
- Sequential brand statements and manifesto sections
@@ -41,23 +41,14 @@ Each enter/exit pair is a `@keyframes` rule:
@keyframes xSL { from { opacity:1; transform:translateX(0) } to { opacity:0; transform:translateX(60px) } }
```
-The sequences loop by resetting `idx` to 0 after the last phrase:
-
-```js
-function cycle(idx = 0) {
- show(PHRASES[idx], () => {
- cycle((idx + 1) % PHRASES.length);
- });
-}
-```
+One play shows the phrases in order and leaves the last one on screen. While Loop is on, the last phrase exits too and the play starts again from the first.
## Key parameters
| Parameter | Default | Effect |
|-----------|---------|--------|
-| Enter duration | 500ms | Fast entry (300ms) = energetic; slow entry (800ms) = deliberate |
-| Hold duration | 2000ms | Must exceed reading time: ~200ms per word minimum |
-| Exit duration | 400ms | Usually shorter than enter — departure is punctuation, not the main event |
-| Enter/exit pairing | Thematic | Matching directions (exit left → enter from left) implies continuation; mismatched implies contrast |
+| Entrance speed | Normal | How long each phrase takes to arrive: slow is 800ms, normal 500ms and fast 300ms; fast feels energetic, slow feels deliberate |
+| Time on each phrase | Medium | How long each phrase holds still: short is 1200ms, medium 2000ms and long 3200ms; it must be longer than it takes to read the phrase |
+| Exit speed | Normal | How long each phrase takes to leave: slow is 650ms, normal 400ms and fast 250ms; exits are usually shorter than entrances |
## Production notes
- **Hold duration is the most important parameter**: the animation is wasted if phrases don't have enough time to be read. A 5-word phrase needs at least 1000ms hold, preferably 1500–2000ms. Test by reading the phrase aloud at a comfortable pace — if you can't finish before the exit starts, extend the hold.
@@ -67,6 +58,6 @@ function cycle(idx = 0) {
- **Framer Motion**: `<AnimatePresence>` handles enter/exit lifecycles for React components elegantly. Each phrase is conditionally rendered and gets `initial`, `animate`, and `exit` props.
## See also
-- [Kinetic Typography](../kinetic-typography/) — the same pattern with per-phrase choreography choices driven by the copy's meaning
-- [Rotate Word Carousel](../rotate-word-carousel/) — a single word within a static sentence cycling through a list
-- [Text Morphing](../text-morphing/) — character-level transitions rather than full-phrase enter/exit
+- [Kinetic Typography](../kinetic-typography/) — words that each move in their own way
+- [Rotate Word Carousel](../rotate-word-carousel/) — one word in a sentence keeps changing
+- [Text Morphing](../text-morphing/) — one word changes into the next, letter by letter
diff --git a/animations/05-text-typography/enter-exit-typography/index.html b/animations/05-text-typography/enter-exit-typography/index.html
index 3b461907..cf78f602 100644
--- a/animations/05-text-typography/enter-exit-typography/index.html
+++ b/animations/05-text-typography/enter-exit-typography/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Enter/Exit Typography — Animation Handbook</title>
- <meta name="description" content="Three-act phrase lifecycle: enter → hold → exit. Each phrase has its own choreography pair.">
+ <meta name="description" content="Each phrase comes in, stays long enough to read, then leaves. Best for slogans.">
<link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/enter-exit-typography/">
<link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png">
<link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
@@ -12,34 +12,20 @@
<meta property="og:type" content="article">
<meta property="og:site_name" content="Animation Handbook">
<meta property="og:title" content="Enter/Exit Typography — Animation Handbook">
- <meta property="og:description" content="Three-act phrase lifecycle: enter → hold → exit. Each phrase has its own choreography pair.">
+ <meta property="og:description" content="Each phrase comes in, stays long enough to read, then leaves. Best for slogans.">
<meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/enter-exit-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="Enter/Exit Typography — Animation Handbook">
- <meta name="twitter:description" content="Three-act phrase lifecycle: enter → hold → exit. Each phrase has its own choreography pair.">
+ <meta name="twitter:description" content="Each phrase comes in, stays long enough to read, then leaves. Best for slogans.">
<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": "Enter/Exit Typography", "name": "Enter/Exit Typography", "description": "Three-act phrase lifecycle: enter → hold → exit. Each phrase has its own choreography pair.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/enter-exit-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, Enter/Exit Typography"}</script>
+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Enter/Exit Typography", "name": "Enter/Exit Typography", "description": "Each phrase comes in, stays long enough to read, then leaves. Best for slogans.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/enter-exit-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, Enter/Exit 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;--enter-dur:500ms;--hold-dur:2000ms;--exit-dur:400ms;--enter-ease:ease-out;--exit-ease:ease-in}
+ :root{--ui-accent:#ff6f8b;--enter-dur:500ms;--exit-dur:400ms;--enter-ease:ease-out;--exit-ease:ease-in}
*,*::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(11px,1.8vw,15px);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}
- /* Phrase container */
- .phrase-el{
- position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
- padding:32px;text-align:center;will-change:transform,opacity,filter;pointer-events:none
- }
- .phrase-text{font-family:Georgia,'Times New Roman',serif;font-size:clamp(28px,5vw,56px);line-height:1.2;color:#fff;font-style:italic}
- /* Enter states */
+ .stage{display:flex;align-items:center;justify-content:center;background:#04060c;position:relative}
+ .phrase-el{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:32px;text-align:center;will-change:transform,opacity,filter;pointer-events:none}
+ .phrase-text{font-size:clamp(28px,5vw,56px);line-height:1.2;color:#fff;font-weight:700}
.state-hidden{opacity:0}
.enter-slide-up{animation:eSU var(--enter-dur) var(--enter-ease) forwards}
.enter-slide-right{animation:eSR var(--enter-dur) var(--enter-ease) forwards}
@@ -51,7 +37,6 @@
@keyframes eSc{from{opacity:0;transform:scale(.7)}to{opacity:1;transform:scale(1)}}
@keyframes eBl{from{opacity:0;filter:blur(12px)}to{opacity:1;filter:blur(0)}}
@keyframes eCl{from{opacity:1;clip-path:inset(0 100% 0 0)}to{opacity:1;clip-path:inset(0 0% 0 0)}}
- /* Exit states */
.exit-slide-up{animation:xSU var(--exit-dur) var(--exit-ease) forwards}
.exit-slide-left{animation:xSL var(--exit-dur) var(--exit-ease) forwards}
.exit-scale{animation:xSc var(--exit-dur) var(--exit-ease) forwards}
@@ -62,162 +47,181 @@
@keyframes xSc{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.6)}}
@keyframes xBl{from{opacity:1;filter:blur(0)}to{opacity:0;filter:blur(12px)}}
@keyframes xCl{from{opacity:1;clip-path:inset(0 0% 0 0)}to{opacity:1;clip-path:inset(0 100% 0 0)}}
- /* Progress */
- .prog-dots{position:absolute;bottom:14px;left:50%;transform:translateX(-50%);display:flex;gap:6px}
- .prog-dot{width:6px;height:6px;border-radius:50%;background:var(--ui-border);transition:background .2s}
- .prog-dot.active{background:var(--ui-accent)}
- /* 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:44px;text-align:right;color:var(--ui-text)}
- select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
- button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%;min-height:44px}
- @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
- .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}
- @media(max-width:600px){.layout{flex-direction:column;align-items:stretch}aside{width:100%}:root{--stage-h:480px}.stage{flex:none}}
@media(prefers-reduced-motion:reduce){.phrase-el{animation:none!important;opacity:1!important;transform:none!important;filter: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="../outline-to-fill/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../rotate-word-carousel/" 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/enter-exit-typography/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>
-<header>
- <h1>Enter/Exit Typography</h1>
- <p>Three-act phrase lifecycle: enter → hold → exit. Each phrase has its own choreography pair.</p>
-</header>
-<div class="layout">
- <div class="stage" id="stage">
- <div class="phrase-el state-hidden" id="phrase-el" aria-live="polite">
- <div class="phrase-text" id="phrase-text"></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="../outline-to-fill/" rel="prev" aria-label="Previous: Outline to Fill"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg><span><span class="hb-dir">Previous: </span>Outline to Fill</span></a><a href="../rotate-word-carousel/" rel="next" aria-label="Next: Rotate Word Carousel"><span><span class="hb-dir">Next: </span>Rotate Word Carousel</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.10 · Text &amp; Typography</p>
+ <h1>Enter/Exit Typography</h1>
+ <p class="hb-lede">Each phrase comes in, stays long enough to read, then leaves. Best for slogans.</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="prog-dots" id="prog-dots"></div>
- </div>
- <aside>
- <p class="note">Three acts per phrase: enter, hold, exit. The hold is where reading happens. Match exit direction to the next phrase's enter direction for visual continuity.</p>
- <div class="lbl">Enter Duration</div>
- <div class="sr"><input type="range" id="enter-sl" min="200" max="1000" value="500" step="50"><span class="sv" id="enter-v">500ms</span></div>
- <div class="lbl">Hold Duration</div>
- <div class="sr"><input type="range" id="hold-sl" min="500" max="4000" value="2000" step="100"><span class="sv" id="hold-v">2.0s</span></div>
- <div class="lbl">Exit Duration</div>
- <div class="sr"><input type="range" id="exit-sl" min="200" max="800" value="400" step="50"><span class="sv" id="exit-v">400ms</span></div>
- <div class="div"></div>
- <div class="kv"><span>Phrase</span><span class="v" id="phrase-kv">1 / 5</span></div>
- <div class="kv"><span>Phase</span><span class="v" id="phase-kv">—</span></div>
- <div class="div"></div>
- <button class="rst" id="replay-btn">↺ Replay</button>
- <label class="tog"><input type="checkbox" id="loop-tog" checked><span>Loop</span></label>
- </aside>
-</div>
-<script>
-const PHRASES=[
- {text:'Everything starts',enter:'enter-slide-right',exit:'exit-slide-up'},
- {text:'with a blank page.',enter:'enter-slide-up',exit:'exit-blur'},
- {text:'Then words arrive.',enter:'enter-blur',exit:'exit-slide-left'},
- {text:'Then motion.',enter:'enter-scale',exit:'exit-scale'},
- {text:'Then meaning.',enter:'enter-clip',exit:'exit-clip'},
-];
-let idx=0,timer=null,run=0;
-const phraseEl=document.getElementById('phrase-el');
-const phraseText=document.getElementById('phrase-text');
-const dotsEl=document.getElementById('prog-dots');
-const phraseKv=document.getElementById('phrase-kv');
-const phaseKv=document.getElementById('phase-kv');
+ <div class="stage hb-dots">
+ <div class="phrase-el state-hidden" id="phrase-el" aria-live="polite">
+ <div class="phrase-text" id="phrase-text"></div>
+ </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="enter-lbl">Entrance speed</p>
+ <div class="seg" id="enter-seg" role="group" aria-labelledby="enter-lbl">
+ <button type="button" data-ms="800" aria-pressed="false">Slow</button>
+ <button type="button" data-ms="500" class="on" aria-pressed="true">Normal</button>
+ <button type="button" data-ms="300" aria-pressed="false">Fast</button>
+ </div>
+ <p class="hb-hint">How quickly each phrase arrives.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="hold-lbl">Time on each phrase</p>
+ <div class="seg" id="hold-seg" role="group" aria-labelledby="hold-lbl">
+ <button type="button" data-ms="1200" aria-pressed="false">Short</button>
+ <button type="button" data-ms="2000" class="on" aria-pressed="true">Medium</button>
+ <button type="button" data-ms="3200" aria-pressed="false">Long</button>
+ </div>
+ <p class="hb-hint">How long each phrase holds still to be read.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="exit-lbl">Exit speed</p>
+ <div class="seg" id="exit-seg" role="group" aria-labelledby="exit-lbl">
+ <button type="button" data-ms="650" aria-pressed="false">Slow</button>
+ <button type="button" data-ms="400" class="on" aria-pressed="true">Normal</button>
+ <button type="button" data-ms="250" aria-pressed="false">Fast</button>
+ </div>
+ <p class="hb-hint">Exits usually run a little faster than entrances.</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 an enter-and-exit text sequence to [the short phrases you want to show]. Show one phrase at a time in the same place: each phrase comes in, holds still long enough to be read, then leaves before the next one arrives. Give each phrase its own way in and out, such as sliding, growing, blurring or wiping, and let each exit lead into the next entrance so the sequence feels connected. Leave the last phrase on screen when the sequence ends. Screen readers should hear each phrase as it appears. If the visitor has reduced motion turned on, swap 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>
-function buildDots(){
- dotsEl.innerHTML='';
- PHRASES.forEach((_,i)=>{const d=document.createElement('div');d.className='cycle-dot prog-dot';dotsEl.appendChild(d);});
-}
-function activeDot(i){dotsEl.querySelectorAll('.prog-dot').forEach((d,j)=>d.classList.toggle('active',j===i));}
+ <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>Brand statements</li><li>Hero messages</li><li>Screens and signage</li></ul>
+ <h3>Avoid on</h3>
+ <ul class="hb-tags hb-avoid"><li>Long sentences</li><li>Key information</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 phraseEl=document.getElementById('phrase-el');
+ const phraseText=document.getElementById('phrase-text');
+ 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 enterMs=500,holdMs=2000,exitMs=400,timers=[];
-function getEnterDur(){return+document.getElementById('enter-sl').value}
-function getHoldDur(){return+document.getElementById('hold-sl').value}
-function getExitDur(){return+document.getElementById('exit-sl').value}
+ const PHRASES=[
+ {text:'Everything starts',enter:'enter-slide-right',exit:'exit-slide-up'},
+ {text:'with a blank page.',enter:'enter-slide-up',exit:'exit-blur'},
+ {text:'Then words arrive.',enter:'enter-blur',exit:'exit-slide-left'},
+ {text:'Then motion.',enter:'enter-scale',exit:'exit-scale'},
+ {text:'Then meaning.',enter:'enter-clip',exit:'exit-clip'},
+ ];
+ const allPhaseClasses=[...PHRASES.map(p=>p.enter),...PHRASES.map(p=>p.exit),'state-hidden'];
-const enterClasses=['enter-slide-up','enter-slide-right','enter-scale','enter-blur','enter-clip'];
-const exitClasses=['exit-slide-up','exit-slide-left','exit-scale','exit-blur','exit-clip'];
-const allPhaseClasses=[...enterClasses,...exitClasses,'state-hidden'];
+ function enterDur(){return slowTog.checked?enterMs*3:enterMs}
+ function exitDur(){return slowTog.checked?exitMs*3:exitMs}
+ function apply(){
+ vars.setProperty('--enter-dur',enterDur()+'ms');
+ vars.setProperty('--exit-dur',exitDur()+'ms');
+ }
+ function later(fn,wait){timers.push(setTimeout(fn,wait))}
-function show(i,done){
- const p=PHRASES[i],r=run;
- phraseText.textContent=p.text;
- phraseEl.classList.remove(...allPhaseClasses);
- phraseEl.classList.add('state-hidden');
- phraseKv.textContent=(i+1)+' / '+PHRASES.length;
- activeDot(i);
- requestAnimationFrame(()=>requestAnimationFrame(()=>{
- if(r!==run)return;
- phaseKv.textContent='Enter';
+ // Resets the phrase hidden, then shows it with its enter class. Runs at the start of every phrase,
+ // including the first one of a play, so each phrase always animates in from the start.
+ function showPhrase(i){
+ const p=PHRASES[i];
+ phraseText.textContent=p.text;
+ phraseEl.classList.remove(...allPhaseClasses);
+ phraseEl.classList.add('state-hidden');
+ void phraseEl.offsetWidth;
phraseEl.classList.remove('state-hidden');
phraseEl.classList.add(p.enter);
- const enterDur=getEnterDur();
- timer=setTimeout(()=>{
- phaseKv.textContent='Hold';
- timer=setTimeout(()=>{
- phaseKv.textContent='Exit';
+ }
+
+ // Plays phrase i: enter, hold, exit, then the next phrase starts 120ms later. The last phrase stays
+ // on screen after its hold; while Loop is on it exits too and the play restarts from the first phrase.
+ function step(i){
+ apply();
+ showPhrase(i);
+ later(()=>{
+ const last=i===PHRASES.length-1;
+ if(last&&(!loopTog.checked||!motionOk))return;
+ const p=PHRASES[i];
+ later(()=>{
phraseEl.classList.remove(p.enter);
phraseEl.classList.add(p.exit);
- timer=setTimeout(()=>{phraseEl.classList.add('state-hidden');done();},getExitDur()+50);
- },getHoldDur());
- },enterDur+50);
- }));
-}
-
-function cycle(){
- show(idx,()=>{
- idx=(idx+1)%PHRASES.length;
- if(idx>0||document.getElementById('loop-tog').checked){
- timer=setTimeout(cycle,120);
- }else{phaseKv.textContent='Done';}
- });
-}
-
-function start(){
- if(timer)clearTimeout(timer);run++;
- idx=0;buildDots();
- phraseEl.classList.remove(...allPhaseClasses);
- phraseEl.classList.add('state-hidden');
- timer=setTimeout(cycle,200);
-}
-
-document.getElementById('replay-btn').addEventListener('click',start);
-// re-enabling Loop after the sequence finished restarts it (sibling demos behave this way)
-document.getElementById('loop-tog').addEventListener('change',e=>{
- if(e.target.checked&&phaseKv.textContent==='Done')start();
-});
-document.getElementById('enter-sl').addEventListener('input',e=>{
- document.getElementById('enter-v').textContent=e.target.value+'ms';
- document.documentElement.style.setProperty('--enter-dur',e.target.value+'ms');
-});
-document.getElementById('hold-sl').addEventListener('input',e=>{
- document.getElementById('hold-v').textContent=(e.target.value/1000).toFixed(1)+'s';
- document.documentElement.style.setProperty('--hold-dur',e.target.value+'ms');
-});
-document.getElementById('exit-sl').addEventListener('input',e=>{
- document.getElementById('exit-v').textContent=e.target.value+'ms';
- document.documentElement.style.setProperty('--exit-dur',e.target.value+'ms');
-});
+ later(()=>later(()=>step(last?0:i+1),120),exitDur()+50);
+ },holdMs);
+ },enterDur()+50);
+ }
+ function play(){timers.forEach(clearTimeout);timers=[];step(0)}
-start();
+ 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('enter-seg',d=>{enterMs=+d.ms});
+ choices('hold-seg',d=>{holdMs=+d.ms});
+ choices('exit-seg',d=>{exitMs=+d.ms});
+ 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 0370605e..0037b808 100644
--- a/index.html
+++ b/index.html
@@ -996,7 +996,7 @@ const CATS=[
['text-morphing','Text Morphing','One word transitions into another character by character — each letter slides out as the next slides in.'],
['text-gradient-animation','Text Gradient Animation','background-clip: text with animated background-position flows color through the characters.'],
['outline-to-fill','Outline to Fill','Hollow stroke letterforms fill with color — clip-path reveal or opacity crossfade.'],
- ['enter-exit-typography','Enter/Exit Typography','Three-act phrase lifecycle: enter → hold → exit, sequenced for storytelling.'],
+ ['enter-exit-typography','Enter/Exit Typography','Each phrase comes in, stays long enough to read, then leaves. Best for slogans.'],
['rotate-word-carousel','Rotate Word Carousel','One keyword cycles through a list while the surrounding sentence stays static.'],
['glitch-text','Glitch Text','RGB-split copies jitter behind animated clip-path slices — the datamosh / signal-loss aesthetic.'],
['text-on-path','Text on a Path','Text flows along an SVG curve via textPath with an animated startOffset — wave, arc, or circle.'],