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
feat: move Text Clip-Path Reveal to the guided-steps page
matin938063f6ceda
diff --git a/animations/05-text-typography/text-clip-path-reveal/README.md b/animations/05-text-typography/text-clip-path-reveal/README.mdindex 0619a702..1e74e58d 100644--- a/animations/05-text-typography/text-clip-path-reveal/README.md+++ b/animations/05-text-typography/text-clip-path-reveal/README.md@@ -1,7 +1,7 @@# Text Clip-Path Reveal## What it is-A text clip-path reveal conceals a fully-rendered headline behind a mask and progressively expands that mask to uncover the text. The text is laid out at full quality from the first frame — kerning, ligatures, and spacing are all computed before the animation starts. Only visibility changes, never the text itself. This makes it superior to character-stagger approaches for preserving typographic precision.+A text clip-path reveal uncovers a headline one line at a time, as if a hidden window opens across each line. Every letter sits in its final place from the start; only the visible part of each line grows. Because the text itself never moves, its spacing stays exactly as designed, which is hard to keep when each letter is animated on its own.## When to use it- Multi-line display headlines that should read as a single composed unit@@ -54,10 +54,11 @@ All resolve to `inset(0 0% 0 0)` when revealed — a single `.revealed` class ha## Key parameters| Parameter | Default | Effect ||-----------|---------|--------|-| Line duration | 700ms | 300ms = snappy swipe; 1200ms = cinematic wipe |-| Stagger | 180ms | Gap between lines starting — 100–200ms feels like a natural cascade |-| Easing | ease-out | Deceleration makes the reveal feel physical; linear feels mechanical |-| Direction | Left→Right | Matches reading direction; RTL matches RTL scripts; TTB works for display headers |+| Starts from | Left | The side each line's wipe begins on: left follows the reading order, right suits right-to-left scripts, top works for display headings |+| Speed | Normal | How long each line takes to uncover: slow is 1100ms, normal 700ms and fast 400ms |+| Delay between lines | Medium | The wait before each next line starts: short is 100ms, medium 180ms and long 300ms; 100 to 200ms reads as a natural cascade |+| Feel | Smooth | Smooth slows to a stop, which feels physical; Gentle eases in and out; Even feels mechanical |+| Your lines | Good design / Is honest / Always. | The headline, one line per row |## Production notes- **No layout shift**: unlike character stagger, clip-path reveal has zero impact on layout — the text is always in its final position, just hidden. This means no reflows and no risk of line-break changes mid-animation.@@ -67,6 +68,6 @@ All resolve to `inset(0 0% 0 0)` when revealed — a single `.revealed` class ha- **Intersection Observer pairing**: in production, trigger the reveal when the headline scrolls into view using `IntersectionObserver`. The demo triggers on load/replay; combine with the [Reveal on Scroll](../../01-scroll-based/reveal-on-scroll/) pattern for scroll-triggered variants.## See also-- [Clip-Path Reveal](../../02-entrance-and-exit/clip-path-reveal/) — the same technique applied to arbitrary elements, not specifically text-- [Curtain Reveal](../../02-entrance-and-exit/curtain-reveal/) — a colored overlay slides over then off, instead of unmasking the element directly-- [Enter/Exit Typography](../enter-exit-typography/) — clip reveal as one of several possible enter choreographies+- [Clip-Path Reveal](../../02-entrance-and-exit/clip-path-reveal/) — a shape uncovers any element+- [Curtain Reveal](../../02-entrance-and-exit/curtain-reveal/) — a colored panel covers it, then slides away+- [Enter/Exit Typography](../enter-exit-typography/) — each phrase comes in, holds and leavesdiff --git a/animations/05-text-typography/text-clip-path-reveal/index.html b/animations/05-text-typography/text-clip-path-reveal/index.htmlindex edd296da..1c28c6e6 100644--- a/animations/05-text-typography/text-clip-path-reveal/index.html+++ b/animations/05-text-typography/text-clip-path-reveal/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Text Clip-Path Reveal — Animation Handbook</title>- <meta name="description" content="Headline reveals line-by-line via an expanding clip-path mask — preserves kerning and spacing perfectly.">+ <meta name="description" content="Each line of a headline is uncovered in turn. Best for big headlines."><link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/text-clip-path-reveal/"><link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">@@ -12,33 +12,23 @@<meta property="og:type" content="article"><meta property="og:site_name" content="Animation Handbook"><meta property="og:title" content="Text Clip-Path Reveal — Animation Handbook">- <meta property="og:description" content="Headline reveals line-by-line via an expanding clip-path mask — preserves kerning and spacing perfectly.">+ <meta property="og:description" content="Each line of a headline is uncovered in turn. Best for big headlines."><meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/text-clip-path-reveal/"><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="Text Clip-Path Reveal — Animation Handbook">- <meta name="twitter:description" content="Headline reveals line-by-line via an expanding clip-path mask — preserves kerning and spacing perfectly.">+ <meta name="twitter:description" content="Each line of a headline is uncovered in turn. Best for big headlines."><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": "Text Clip-Path Reveal", "name": "Text Clip-Path Reveal", "description": "Headline reveals line-by-line via an expanding clip-path mask — preserves kerning and spacing perfectly.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/text-clip-path-reveal/", "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, Text Clip-Path Reveal"}</script>+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Text Clip-Path Reveal", "name": "Text Clip-Path Reveal", "description": "Each line of a headline is uncovered in turn. Best for big headlines.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/text-clip-path-reveal/", "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, Text Clip-Path Reveal"}</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;--line-dur:700ms;--stagger:180ms;--ease:ease-out}+ :root{--ui-accent:#ff6f8b;--line-dur:700ms;--ease:ease-out}*,*::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;min-height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;background:#08080a;display:flex;align-items:center;justify-content:center;padding:clamp(24px,4vw,48px)}+ .stage{display:flex;align-items:center;justify-content:center;background:#04060c;padding:clamp(24px,4vw,48px)}.headline{display:flex;flex-direction:column;gap:4px;overflow:visible}.line-wrap{overflow:hidden;line-height:1.15}.line-text{- font-family:Georgia,'Times New Roman',serif;- font-size:clamp(36px,6vw,72px);- font-style:italic;+ font-size:clamp(28px,5vw,56px);+ font-weight:700;line-height:1.15;color:#fff;display:block;@@ -48,139 +38,198 @@.line-text.dir-rtl{clip-path:inset(0 0 0 100%)}.line-text.dir-ttb{clip-path:inset(0 0 100% 0)}.line-text.revealed{clip-path:inset(0 0% 0 0)!important}- /* 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)}- .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:var(--mono);font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}- textarea{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:var(--mono);font-size:10px;padding:8px;border-radius:4px;width:100%;resize:vertical;min-height:72px;line-height:1.5;outline:none}- textarea:focus{border-color:var(--ui-accent)}- 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%;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}aside{width:100%}:root{--stage-h:auto}.stage{width:100%;height:auto;min-height:360px}}@media(prefers-reduced-motion:reduce){.line-text{clip-path:inset(0)!important;transition: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="../variable-font-morph/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../marquee-ticker/" 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/text-clip-path-reveal/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>-<header>- <h1>Text Clip-Path Reveal</h1>- <p>Headline reveals line-by-line via an expanding clip-path mask — preserves kerning and spacing perfectly.</p>-</header>-<div class="layout">- <div class="stage">- <div class="headline" id="headline" aria-live="polite"></div>- </div>- <aside>- <p class="note">clip-path reveal preserves typographic quality — the text is fully laid out from the start, only progressively visible. Character-stagger methods can disrupt kerning.</p>- <div class="lbl">Direction</div>- <select id="dir-sel">- <option value="ltr" selected>Left → Right</option>- <option value="rtl">Right → Left</option>- <option value="ttb">Top → Bottom</option>- </select>- <div class="lbl">Line Duration</div>- <div class="sr"><input type="range" id="dur-sl" min="300" max="1200" value="700" step="50"><span class="sv" id="dur-v">700ms</span></div>- <div class="lbl">Stagger Between Lines</div>- <div class="sr"><input type="range" id="stag-sl" min="80" max="400" value="180" step="20"><span class="sv" id="stag-v">180ms</span></div>- <div class="lbl">Easing</div>- <select id="ease-sel">- <option value="ease-out" selected>Ease out</option>- <option value="ease-in-out">Ease in-out</option>- <option value="linear">Linear</option>- <option value="cubic-bezier(.2,.7,.3,1)">Smooth</option>- </select>- <div class="div"></div>- <div class="lbl">Lines (one per line)</div>- <textarea id="lines-inp">Good design+<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="../variable-font-morph/" rel="prev" aria-label="Previous: Variable Font Morph"><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>Variable Font Morph</span></a><a href="../marquee-ticker/" rel="next" aria-label="Next: Marquee / Ticker"><span><span class="hb-dir">Next: </span>Marquee / Ticker</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.05 · Text & Typography</p>+ <h1>Text Clip-Path Reveal</h1>+ <p class="hb-lede">Each line of a headline is uncovered in turn. Best for big headlines.</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 hb-grow">+ <div class="headline" id="headline" 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="dir-lbl">Starts from</p>+ <div class="seg" id="dir-seg" role="group" aria-labelledby="dir-lbl">+ <button type="button" data-dir="ltr" class="on" aria-pressed="true">Left</button>+ <button type="button" data-dir="rtl" aria-pressed="false">Right</button>+ <button type="button" data-dir="ttb" aria-pressed="false">Top</button>+ </div>+ <p class="hb-hint">The side each line's wipe begins on.</p>+ </div>+ <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-ms="1100" aria-pressed="false">Slow</button>+ <button type="button" data-ms="700" class="on" aria-pressed="true">Normal</button>+ <button type="button" data-ms="400" aria-pressed="false">Fast</button>+ </div>+ <p class="hb-hint">How long each line takes to uncover.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="delay-lbl">Delay between lines</p>+ <div class="seg" id="delay-seg" role="group" aria-labelledby="delay-lbl">+ <button type="button" data-ms="100" aria-pressed="false">Short</button>+ <button type="button" data-ms="180" class="on" aria-pressed="true">Medium</button>+ <button type="button" data-ms="300" aria-pressed="false">Long</button>+ </div>+ <p class="hb-hint">Longer delays make the cascade easier to see.</p>+ </div>+ </div>+ <details class="hb-options">+ <summary><span class="hb-more-label">More options</span><span class="hb-less">Fewer options</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></summary>+ <div class="hb-settings">+ <div class="hb-setting">+ <p class="hb-setting-name" id="feel-lbl">Feel</p>+ <div class="seg" id="feel-seg" role="group" aria-labelledby="feel-lbl">+ <button type="button" data-ease="ease-out" class="on" aria-pressed="true">Smooth</button>+ <button type="button" data-ease="ease-in-out" aria-pressed="false">Gentle</button>+ <button type="button" data-ease="linear" aria-pressed="false">Even</button>+ </div>+ <p class="hb-hint">Smooth slows at the end; Even keeps one pace.</p>+ </div>+ <div class="hb-setting">+ <label class="hb-setting-name" for="lines-in">Your lines</label>+ <textarea class="hb-text" id="lines-in" autocomplete="off">Good designIs honestAlways.</textarea>- <button class="rst" id="replay-btn">↺ Replay</button>- <label class="tog"><input type="checkbox" id="loop-tog"><span>Auto-loop</span></label>- </aside>-</div>+ <p class="hb-hint">Put each line on a row of its own.</p>+ </div>+ </div>+ </details>+ </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 line-by-line reveal to [your multi-line headline]. Lay out every line in its final place from the start, then uncover each line with a wipe that grows from one side until the whole line shows, starting each line a moment after the one above so the headline cascades in. Nothing moves or changes size; only the visible part of each line grows, so the letter spacing stays exactly as designed. A wipe that slows down as it finishes looks calmer than one that stops abruptly. The text must stay readable by screen readers the whole time. If the visitor has reduced motion turned on, show all the lines at once. 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>Headlines</li><li>Taglines</li><li>Portfolios</li></ul>+ <h3>Avoid on</h3>+ <ul class="hb-tags hb-avoid"><li>Body text</li><li>Buttons and labels</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 headline=document.getElementById('headline');- let loopTimer=null,lineTimers=[];- const reducedMotion=matchMedia('(prefers-reduced-motion: reduce)');+ const vars=document.documentElement.style;+ const loopTog=document.getElementById('loop-tog'),slowTog=document.getElementById('slow-tog');+ const linesIn=document.getElementById('lines-in');+ const motionOk=!window.matchMedia('(prefers-reduced-motion:reduce)').matches;+ const DEFAULT_LINES=['Good design','Is honest','Always.'];+ let dir='ltr',dur=700,stag=180,ease='ease-out',timers=[];- function getDir(){return document.getElementById('dir-sel').value}- function getDirClass(dir){- if(dir==='rtl')return 'dir-rtl';- if(dir==='ttb')return 'dir-ttb';- return '';+ function lineDur(){return slowTog.checked?dur*3:dur}+ function gapDur(){return slowTog.checked?stag*3:stag}+ function apply(){+ vars.setProperty('--line-dur',lineDur()+'ms');+ vars.setProperty('--ease',ease);}+ function later(fn,wait){timers.push(setTimeout(fn,wait))}+ // Rebuilds the lines hidden from the current text and direction. Runs directly on every keystroke in+ // Your lines, so the stage always shows the right lines, and again at the start of every play.function buildLines(){- const text=document.getElementById('lines-inp').value;- const lines=text.split('\n').filter(l=>l.trim());+ const rows=linesIn.value.split('\n').map(l=>l.trim()).filter(Boolean);+ const useRows=rows.length?rows:DEFAULT_LINES;headline.innerHTML='';- return lines.map(line=>{+ return useRows.map(line=>{const wrap=document.createElement('div');wrap.className='line-wrap';const span=document.createElement('span');span.className='line-text';- const dir=getDir();- if(dir!=='ltr')span.classList.add(getDirClass(dir));+ if(dir!=='ltr')span.classList.add(dir==='rtl'?'dir-rtl':'dir-ttb');span.textContent=line;wrap.appendChild(span);headline.appendChild(wrap);return span;});}- function reveal(){- if(loopTimer){clearTimeout(loopTimer);loopTimer=null}- lineTimers.forEach(clearTimeout);lineTimers=[];- const dur=+document.getElementById('dur-sl').value;- const stag=+document.getElementById('stag-sl').value;- document.documentElement.style.setProperty('--line-dur',dur+'ms');- document.documentElement.style.setProperty('--stagger',stag+'ms');- document.documentElement.style.setProperty('--ease',document.getElementById('ease-sel').value);-+ // One play reveals the lines in turn. While Loop is on, the last line's reveal is followed by a 1200ms+ // hold; whether the lines then vanish and the play starts again is decided right after that hold, from+ // Loop's value at that moment, so switching Loop off during the hold still leaves the lines shown.+ function cycle(){+ apply();const lines=buildLines();- void headline.offsetWidth; // flush styles so the new spans have a clip-path start value to transition from+ void headline.offsetWidth;+ const gap=gapDur();lines.forEach((span,i)=>{- lineTimers.push(setTimeout(()=>{span.classList.add('revealed');},50+stag*i));+ later(()=>{span.classList.add('revealed')},50+gap*i);});-- if(document.getElementById('loop-tog').checked&&!reducedMotion.matches){- const total=50+stag*(lines.length-1)+dur+1200;- loopTimer=setTimeout(reveal,total);- }+ later(()=>{+ if(!loopTog.checked||!motionOk)return;+ cycle();+ },50+gap*(lines.length-1)+lineDur()+1200);}+ function play(){timers.forEach(clearTimeout);timers=[];cycle()}- document.getElementById('replay-btn').addEventListener('click',reveal);- document.getElementById('dur-sl').addEventListener('input',e=>{- document.getElementById('dur-v').textContent=e.target.value+'ms';- document.documentElement.style.setProperty('--line-dur',e.target.value+'ms');- });- document.getElementById('stag-sl').addEventListener('input',e=>document.getElementById('stag-v').textContent=e.target.value+'ms');- document.getElementById('dir-sel').addEventListener('change',reveal);- document.getElementById('ease-sel').addEventListener('change',reveal);- document.getElementById('loop-tog').addEventListener('change',e=>{- if(e.target.checked){reveal();return}- if(loopTimer){clearTimeout(loopTimer);loopTimer=null}- });-- reveal();+ document.getElementById('btn-play').addEventListener('click',play);+ loopTog.addEventListener('change',()=>{if(loopTog.checked)play()});+ linesIn.addEventListener('input',buildLines);+ 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('dir-seg',d=>{dir=d.dir});+ choices('speed-seg',d=>{dur=+d.ms});+ choices('delay-seg',d=>{stag=+d.ms});+ choices('feel-seg',d=>{ease=d.ease});+ 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.htmlindex 13be5b31..e50d67ea 100644--- a/index.html+++ b/index.html@@ -991,7 +991,7 @@ const CATS=[['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','Random symbols lock into the real text, left to right. Best for tech headlines.'],['variable-font-morph','Variable Font Morph','CSS font-variation-settings animates weight, slant, and casual axes of a variable font.'],- ['text-clip-path-reveal','Text Clip-Path Reveal','Lines reveal via expanding clip-path mask — preserves kerning and typographic spacing exactly.'],+ ['text-clip-path-reveal','Text Clip-Path Reveal','Each line of a headline is uncovered in turn. Best for big headlines.'],['marquee-ticker','Marquee / Ticker','Continuous horizontal scroll with seamless loop — duplicated content makes the reset invisible.'],['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.'],