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 Wavy Text to the guided-steps page

matin73d60d46dd93
diff --git a/animations/05-text-typography/wavy-text/README.md b/animations/05-text-typography/wavy-text/README.md
index 2097f0d4..bb71ea40 100644
--- a/animations/05-text-typography/wavy-text/README.md
+++ b/animations/05-text-typography/wavy-text/README.md
@@ -1,7 +1,7 @@
# Wavy Text
## What it is
-Wavy text sends a vertical sine wave rolling across a word. Each character bobs up and down on the same keyframe, but neighbouring letters are offset in time, so the peak of the motion travels from the first letter to the last — like a flag ripple or a row of buoys lifted by a passing swell.
+Wavy text sends a wave rolling across a word. Every letter bobs up and down with the same motion, but each one starts a moment after the letter before it, so the highest point travels from the first letter to the last, like a flag rippling or a row of buoys lifted by a passing swell.
## When to use it
- Playful headlines and logotypes for games, kids' products, or casual brands
@@ -33,24 +33,24 @@ JavaScript splits the string into one `<span>` per character and stamps each wit
}
```
-Only `transform` animates, so the effect stays on the compositor and runs at 60fps. Amplitude, duration, and stagger are all CSS variables the controls rewrite live.
+Only `transform` animates, so the effect stays on the compositor and runs at 60fps. Wave height, Speed and Delay between letters set these three CSS variables.
## Key parameters
| Parameter | Default | Effect |
|-----------|---------|--------|
-| Amplitude | 16px | Vertical travel of each letter; larger = taller wave |
-| Wave speed | 1.6s | Duration of one bob cycle; shorter = faster ripple |
-| Stagger | 60ms | Delay between adjacent letters; larger = longer, more visible wave |
-| Text | user string | The word split into spans; spaces are preserved as gaps |
+| Wave height | Medium | How far each letter travels: low is 8px, medium 16px and high 28px; larger makes a taller wave |
+| Speed | Normal | How long one rise and fall takes: slow is 2.6s, normal 1.6s and fast 1s |
+| Delay between letters | Medium | The gap between neighbouring letters: short is 30ms, medium 60ms and long 120ms; longer delays stretch the wave |
+| Your text | Wavy | The word that waves, up to 14 letters |
## Production notes
- **Accessibility**: splitting text into spans destroys the readable word for assistive tech. The demo sets `aria-label` on the container and `aria-hidden="true"` on each fragment, so screen readers announce the whole word once instead of spelling it out letter by letter.
-- **Reduced motion**: under `@media (prefers-reduced-motion: reduce)` the span animation and transform are disabled, leaving flat, static text. Vestibular users get no bobbing.
+- **Reduced motion**: under reduced motion the demo starts paused, so the letters stay still until the visitor presses Play. In production, keep the letters still for these visitors.
- **Layout**: use `display:inline-block` on the spans (bare inline elements ignore `transform`) and `white-space:pre` on the container so spaces don't collapse. Emoji and combining characters can break naive `[...str]` splitting — segment with `Intl.Segmenter` if the text is user-supplied.
- **Library equivalents**: GSAP SplitText handles the character splitting and offers a `stagger` option on its tweens; Splitting.js emits `--char-index` custom properties equivalent to the `--i` here, letting you drive the same effect in pure CSS.
## See also
-- [Kinetic Typography](../kinetic-typography/) — the broader family of per-letter motion
-- [Typewriter Effect](../typewriter-effect/) — another per-character reveal technique
-- [Text Morphing](../text-morphing/) — animating letterforms rather than their position
-- [Variable Font Morph](../variable-font-morph/) — animating type via font axes
+- [Kinetic Typography](../kinetic-typography/) — words that each move in their own way
+- [Typewriter Effect](../typewriter-effect/) — text typed one character at a time
+- [Text Morphing](../text-morphing/) — one word changes into the next, letter by letter
+- [Variable Font Morph](../variable-font-morph/) — the letters change weight and lean
diff --git a/animations/05-text-typography/wavy-text/index.html b/animations/05-text-typography/wavy-text/index.html
index e5586531..e540b976 100644
--- a/animations/05-text-typography/wavy-text/index.html
+++ b/animations/05-text-typography/wavy-text/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wavy Text — Animation Handbook</title>
- <meta name="description" content="Each letter is its own span with a staggered animation-delay, so a vertical sine wave travels across the word.">
+ <meta name="description" content="A wave rolls through the word, letter by letter. Best for playful titles.">
<link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/wavy-text/">
<link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png">
<link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
@@ -12,30 +12,19 @@
<meta property="og:type" content="article">
<meta property="og:site_name" content="Animation Handbook">
<meta property="og:title" content="Wavy Text — Animation Handbook">
- <meta property="og:description" content="Each letter is its own span with a staggered animation-delay, so a vertical sine wave travels across the word.">
+ <meta property="og:description" content="A wave rolls through the word, letter by letter. Best for playful titles.">
<meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/wavy-text/">
<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="Wavy Text — Animation Handbook">
- <meta name="twitter:description" content="Each letter is its own span with a staggered animation-delay, so a vertical sine wave travels across the word.">
+ <meta name="twitter:description" content="A wave rolls through the word, letter by letter. Best for playful titles.">
<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": "Wavy Text", "name": "Wavy Text", "description": "Each letter is its own span with a staggered animation-delay, so a vertical sine wave travels across the word.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/wavy-text/", "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, Wavy Text"}</script>
+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Wavy Text", "name": "Wavy Text", "description": "A wave rolls through the word, letter by letter. Best for playful titles.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/wavy-text/", "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, Wavy Text"}</script>
<style>
- :root{
- --bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#ff6f8b;
- --ui-text:#f4f4f2;--ui-muted:#77777e;
- --disp:'Arial Narrow','Segoe UI',system-ui,sans-serif;--mono:ui-monospace,Menlo,Consolas,monospace;
- --stage-h:520px;--amp:16px;--dur:1.6s;--stagger:60ms;
- }
+ :root{--ui-accent:#ff6f8b;--amp:16px;--dur:1.6s;--stagger:60ms}
*,*::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:800;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:radial-gradient(circle at 50% 45%,#101018,#04060c);display:flex;align-items:center;justify-content:center;padding:24px;overflow:hidden}
- .wave-text{font-family:var(--disp);font-weight:800;font-size:clamp(40px,11vw,110px);
+ .stage{display:flex;align-items:center;justify-content:center;background:radial-gradient(circle at 50% 45%,#101018,#04060c);padding:24px;overflow:hidden}
+ .wave-text{font-weight:800;font-size:clamp(40px,11vw,110px);
line-height:1;letter-spacing:.01em;color:#fff;white-space:pre;-webkit-user-select:none;user-select:none}
/* each character is its own span, offset in the wave by --i * stagger */
.wave-text span{display:inline-block;will-change:transform;
@@ -45,98 +34,160 @@
0%,100%{transform:translateY(calc(var(--amp) * .6))}
50%{transform:translateY(calc(var(--amp) * -1))}
}
- 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)}
- .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)}
- input[type=text]{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:var(--mono);font-size:11px;padding:8px 10px;border-radius:4px;width:100%;min-height:44px;outline:none}
- input[type=text]:focus{border-color:var(--ui-accent)}
- .div{height:1px;background:var(--ui-border)}
- @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:auto}.stage{width:100%;height:auto;min-height:340px}}
- @media(prefers-reduced-motion:reduce){
- .wave-text span{animation:none!important;transform: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="../text-on-path/" rel="prev" title="Previous">‹ Prev</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/wavy-text/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>
-<header>
- <h1>Wavy Text</h1>
- <p>Each letter is its own span with a staggered animation-delay, so a vertical sine wave travels across the word.</p>
-</header>
-<div class="layout">
- <div class="stage">
- <div class="wave-text" id="wave" aria-label="Wavy">Wavy</div>
- </div>
- <aside>
- <p class="note">JS splits the string into per-letter spans and sets a --i index on each. A shared bob keyframe plus a delay of i × stagger phases neighbours apart, producing a rolling wave.</p>
- <div class="lbl">Text</div>
- <input type="text" id="text-inp" value="Wavy" maxlength="14">
- <div class="lbl">Amplitude</div>
- <div class="sr"><input type="range" id="amp-sl" min="4" max="40" value="16" step="2"><span class="sv" id="amp-sv">16px</span></div>
- <div class="lbl">Wave speed</div>
- <div class="sr"><input type="range" id="spd-sl" min="1" max="10" value="6" step="1"><span class="sv" id="spd-sv">1.6s</span></div>
- <div class="lbl">Per-letter stagger</div>
- <div class="sr"><input type="range" id="stg-sl" min="0" max="160" value="60" step="10"><span class="sv" id="stg-sv">60ms</span></div>
- </aside>
-</div>
+<body class="hb" data-hb-kind="loop">
+<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="../text-on-path/" rel="prev" aria-label="Previous: Text on a Path"><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>Text on a Path</span></a></span>
+</nav>
+<main class="hb-page">
+ <header class="hb-head">
+ <p class="hb-cat">05.14 · Text &amp; Typography</p>
+ <h1>Wavy Text</h1>
+ <p class="hb-lede">A wave rolls through the word, letter by letter. Best for playful titles.</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 moves by itself. Pause it to look closely, or turn on slow motion to see each part of the movement.</p></div>
+ </div>
+ <div class="stage" id="stage">
+ <div class="wave-text" id="wave" aria-label="Wavy">Wavy</div>
+ </div>
+ <div class="hb-player">
+ <button class="hb-play" type="button" id="btn-pause" data-hb-pause="css" data-state="playing"><svg class="hb-ic hb-i-pause" viewBox="0 0 24 24" aria-hidden="true"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg><svg class="hb-ic hb-i-play" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3l14 9-14 9z"/></svg><span class="hb-pause-label">Pause</span></button>
+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="slow-tog" data-hb-slowmo="css" 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 see the difference as it moves.</p></div>
+ </div>
+ <div class="hb-settings">
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="amp-lbl">Wave height</p>
+ <div class="seg" id="amp-seg" role="group" aria-labelledby="amp-lbl">
+ <button type="button" data-amp="8" aria-pressed="false">Low</button>
+ <button type="button" data-amp="16" class="on" aria-pressed="true">Medium</button>
+ <button type="button" data-amp="28" aria-pressed="false">High</button>
+ </div>
+ <p class="hb-hint">How far each letter rises and falls.</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-dur="2.6s" aria-pressed="false">Slow</button>
+ <button type="button" data-dur="1.6s" class="on" aria-pressed="true">Normal</button>
+ <button type="button" data-dur="1s" aria-pressed="false">Fast</button>
+ </div>
+ <p class="hb-hint">How long one rise and fall takes.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="stag-lbl">Delay between letters</p>
+ <div class="seg" id="stag-seg" role="group" aria-labelledby="stag-lbl">
+ <button type="button" data-stag="30" aria-pressed="false">Short</button>
+ <button type="button" data-stag="60" class="on" aria-pressed="true">Medium</button>
+ <button type="button" data-stag="120" aria-pressed="false">Long</button>
+ </div>
+ <p class="hb-hint">Longer delays stretch the wave across the word.</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">
+ <label class="hb-setting-name" for="text-inp">Your text</label>
+ <input class="hb-text" type="text" id="text-inp" value="Wavy" maxlength="14" autocomplete="off">
+ <p class="hb-hint">Short words work best, up to 14 letters.</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 wavy text effect to [your word or short title]. Split the text into letters and make every letter bob up and down with the same smooth motion, but start each letter a moment after the one before it, so the high point of the wave rolls from the first letter to the last and around again. Keep the letters on one line, and move them only up and down, never changing their size or spacing. Screen readers should read the word once, not letter by letter. If the visitor has reduced motion turned on, keep the letters still. 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>Playful titles</li><li>Games and kids' sites</li><li>Loading text</li></ul>
+ <h3>Avoid on</h3>
+ <ul class="hb-tags hb-avoid"><li>Serious content</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 wave=document.getElementById('wave');
-const root=document.documentElement;
+ const wave=document.getElementById('wave');
+ const stage=document.getElementById('stage');
+ const root=document.documentElement;
+ const txtIn=document.getElementById('text-inp');
+
+ // Split the string into spans, preserving spaces, and index each with --i.
+ function build(str){
+ wave.setAttribute('aria-label',str);
+ wave.textContent='';
+ [...str].forEach((ch,i)=>{
+ const s=document.createElement('span');
+ s.textContent=ch===' '?' ':ch;
+ s.style.setProperty('--i',i);
+ s.setAttribute('aria-hidden','true');
+ wave.appendChild(s);
+ });
+ fit();
+ }
+ // Shrink the type when a long string would spill past the stage edges.
+ function fit(){
+ wave.style.fontSize='';
+ const room=stage.clientWidth-48;
+ if(room>0&&wave.offsetWidth>room) wave.style.fontSize=parseFloat(getComputedStyle(wave).fontSize)*room/wave.offsetWidth+'px';
+ }
+ build('Wavy');
+ addEventListener('resize',fit);
+ if(document.fonts)document.fonts.ready.then(fit); // the site font can still be loading when fit() first runs
-// Split the string into spans, preserving spaces, and index each with --i.
-function build(str){
- wave.setAttribute('aria-label',str);
- wave.textContent='';
- [...str].forEach((ch,i)=>{
- const s=document.createElement('span');
- s.textContent=ch===' '?' ':ch;
- s.style.setProperty('--i',i);
- s.setAttribute('aria-hidden','true');
- wave.appendChild(s);
- });
- fit();
-}
-// Shrink the type when a long string would spill past the stage edges.
-const stage=document.querySelector('.stage');
-function fit(){
- wave.style.fontSize='';
- const room=stage.clientWidth-48;
- if(room>0&&wave.offsetWidth>room) wave.style.fontSize=parseFloat(getComputedStyle(wave).fontSize)*room/wave.offsetWidth+'px';
-}
-build('Wavy');
-addEventListener('resize',fit);
+ txtIn.addEventListener('input',e=>build(e.target.value||'Wavy'));
-document.getElementById('text-inp').addEventListener('input',e=>build(e.target.value||' '));
-document.getElementById('amp-sl').addEventListener('input',e=>{
- root.style.setProperty('--amp',e.target.value+'px');
- document.getElementById('amp-sv').textContent=e.target.value+'px';
-});
-document.getElementById('spd-sl').addEventListener('input',e=>{
- const dur=(11-+e.target.value)*0.32;
- root.style.setProperty('--dur',dur.toFixed(1)+'s');
- document.getElementById('spd-sv').textContent=dur.toFixed(1)+'s';
-});
-document.getElementById('stg-sl').addEventListener('input',e=>{
- root.style.setProperty('--stagger',e.target.value+'ms');
- document.getElementById('stg-sv').textContent=e.target.value+'ms';
-});
+ 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('amp-seg',d=>{root.style.setProperty('--amp',d.amp+'px')});
+ choices('speed-seg',d=>{root.style.setProperty('--dur',d.dur)});
+ choices('stag-seg',d=>{root.style.setProperty('--stagger',d.stag+'ms')});
</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 9fb58c7f..4d518cf1 100644
--- a/index.html
+++ b/index.html
@@ -1000,7 +1000,7 @@ const CATS=[
['rotate-word-carousel','Rotate Word Carousel','One word in a sentence keeps swapping for the next. Best for hero headlines.'],
['glitch-text','Glitch Text','Text tears into red and cyan strips like a broken signal. Best for bold titles.'],
['text-on-path','Text on a Path','Text travels along a wave, an arc or a circle. Best for badges and seals.'],
- ['wavy-text','Wavy Text','Per-letter sine-wave bob with a staggered delay sends a wave travelling across the word.'],
+ ['wavy-text','Wavy Text','A wave rolls through the word, letter by letter. Best for playful titles.'],
]
},
{