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 Notification Badge Pulse to the guided-steps page
matinc5776422b44b
diff --git a/animations/04-micro-interactions/badge-pulse/README.md b/animations/04-micro-interactions/badge-pulse/README.mdindex 2e22dcad..c8b9fe0a 100644--- a/animations/04-micro-interactions/badge-pulse/README.md+++ b/animations/04-micro-interactions/badge-pulse/README.md@@ -1,7 +1,7 @@# Notification Badge Pulse## What it is-A notification badge is a small indicator — a numbered chip or colored dot — overlaid on an icon to signal unread items. The pulse animation (a subtle scale loop) draws peripheral attention without demanding focus. It is one of the most restrained attention-capture patterns in UI: it works in the user's periphery without interrupting their current task.+A notification badge is a small colored dot or number on an icon that marks something new, such as unread messages. A gentle pulse, growing a little and settling back or sending out a soft ring, catches the eye at the edge of your vision without interrupting what you are doing.## When to use it- Notification bells with unread message counts@@ -57,20 +57,21 @@ The halo variant adds a radiating ring that expands and fades:## Key parameters| Parameter | Default | Effect ||-----------|---------|--------|-| Duration | 1500ms | 800ms feels urgent; 3000ms is almost imperceptible; 1500ms is the peripheral-vision sweet spot |-| Scale | 1.3 | 1.1–1.5 range; beyond 1.5 the badge grows large enough to feel alarming |-| Halo style | Scale + halo | Halo alone is subtler; scale alone is more contained |-| Border offset | `border: 2px solid bg` | The badge border must match the icon background to appear floating |+| Pulse style | Grow | Grow scales the badge up and back; Ring sends a soft halo outward; Both does the two together |+| Speed | Normal | How long one pulse takes: slow is 2.4s, normal 1.5s and fast 0.9s; fast feels urgent, slow is easy to miss |+| How much it grows | Medium | How big the badge gets at the top of each pulse: slightly is 115%, medium 130% and a lot 150% of its size |+| Stops after three pulses | off | The badges pulse three times and then rest; the online dot keeps going |+| Badge color | Red | The badge's color; red reads as new and urgent |## Production notes- **Peripheral vision threshold**: 1.15× scale at 1.5s is the minimum perceptible in peripheral vision for most users. Below that, the badge reads as static.- **Dismiss on interaction**: always remove the pulse (and the badge itself) when the user views the notifications. A persistent pulse on already-seen content is confusing.- **Fade-after-attention**: pulse strongly for the first 5 seconds, then reduce scale or stop entirely. This mirrors real notification system behavior (the alert has been "seen" peripherally).- **`border: 2px solid` background color trick**: this makes the badge appear to float above the icon surface with a gap. Update the border color if the icon sits on a non-uniform background.-- **`prefers-reduced-motion`**: disable the pulse animation entirely. The badge remains visible — users who need reduced motion still see the indicator, just without motion.+- **`prefers-reduced-motion`**: under reduced motion the demo starts paused, so the badges stay still until the visitor presses Play. In production, turn the pulse off: the badge stays visible, just without motion.- **React**: `react-hot-toast` and Sonner implement badge-style indicators for toast notifications. For nav badges, most component libraries include a `Badge` with optional `animate` prop.## See also-- [Tooltip Reveal](../tooltip-reveal/) — hover-triggered information on the same icons-- [Loading Spinner](../loading-spinner/) — another attention indicator for active states-- [Hover State Animation](../hover-state/) — hover feedback on the icon behind the badge+- [Tooltip Reveal](../tooltip-reveal/) — pointing at an icon shows a short note+- [Loading Spinner](../loading-spinner/) — another sign that something is going on+- [Hover State Animation](../hover-state/) — items react when the pointer is over themdiff --git a/animations/04-micro-interactions/badge-pulse/index.html b/animations/04-micro-interactions/badge-pulse/index.htmlindex 502dc40d..0ca993a4 100644--- a/animations/04-micro-interactions/badge-pulse/index.html+++ b/animations/04-micro-interactions/badge-pulse/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Notification Badge Pulse — Animation Handbook</title>- <meta name="description" content="Dot on icon pulses to draw peripheral attention — scale, halo, or both.">+ <meta name="description" content="A badge on an icon pulses to catch the eye. Best for unread messages."><link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/04-micro-interactions/badge-pulse/"><link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">@@ -12,35 +12,27 @@<meta property="og:type" content="article"><meta property="og:site_name" content="Animation Handbook"><meta property="og:title" content="Notification Badge Pulse — Animation Handbook">- <meta property="og:description" content="Dot on icon pulses to draw peripheral attention — scale, halo, or both.">+ <meta property="og:description" content="A badge on an icon pulses to catch the eye. Best for unread messages."><meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/04-micro-interactions/badge-pulse/"><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="Notification Badge Pulse — Animation Handbook">- <meta name="twitter:description" content="Dot on icon pulses to draw peripheral attention — scale, halo, or both.">+ <meta name="twitter:description" content="A badge on an icon pulses to catch the eye. Best for unread messages."><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": "Notification Badge Pulse", "name": "Notification Badge Pulse", "description": "Dot on icon pulses to draw peripheral attention — scale, halo, or both.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/04-micro-interactions/badge-pulse/", "inLanguage": "en", "articleSection": "Micro-Interactions", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Micro-Interactions, Notification Badge Pulse"}</script>+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Notification Badge Pulse", "name": "Notification Badge Pulse", "description": "A badge on an icon pulses to catch the eye. Best for unread messages.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/04-micro-interactions/badge-pulse/", "inLanguage": "en", "articleSection": "Micro-Interactions", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Micro-Interactions, Notification Badge Pulse"}</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:#ff9d5c;--ui-text:#f4f4f2;--ui-muted:#77777e;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace;--stage-h:620px;--pulse-dur:1500ms;--pulse-scale:1.3;--badge-color:#f85149}+ :root{--ui-accent:#ff9d5c;--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-muted:#8a8a92;--pulse-dur:1500ms;--pulse-scale:1.3;--badge-color:#f85149}*,*::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:var(--bg);display:flex;align-items:center;justify-content:center;padding:32px}- .icon-row{display:flex;gap:40px;align-items:flex-end}+ .stage{display:flex;align-items:center;justify-content:center;padding:16px;background:#0b0b0d}+ .icon-row{display:flex;gap:clamp(16px,6vw,40px);align-items:flex-end}/* Icon base */.icon-wrap{display:flex;flex-direction:column;align-items:center;gap:12px;position:relative}.icon-btn{width:64px;height:64px;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:28px;position:relative;cursor:pointer;transition:border-color .15s}+ .icon-round{border-radius:50%}@media(hover:hover){.icon-btn:hover{border-color:var(--ui-accent)}}- .icon-label{font-size:10px;color:var(--ui-muted);text-align:center}- /* Badge */- .badge{position:absolute;top:-8px;right:-8px;min-width:22px;height:22px;border-radius:11px;background:var(--badge-color);color:#fff;font-size:10px;font-weight:bold;display:flex;align-items:center;justify-content:center;padding:0 5px;border:2px solid var(--bg)}+ .icon-label{font-size:11px;color:var(--ui-muted);text-align:center}+ /* Badge: the number is dark because white on these colors is below 4.5:1 */+ .badge{position:absolute;top:-8px;right:-8px;min-width:22px;height:22px;border-radius:11px;background:var(--badge-color);color:#0b0b0d;font-size:11px;font-weight:bold;display:flex;align-items:center;justify-content:center;padding:0 5px;border:2px solid var(--bg)}/* Dot badge */.dot-badge{position:absolute;top:-4px;right:-4px;width:14px;height:14px;border-radius:50%;background:var(--badge-color);border:2px solid var(--bg)}/* Pulse scale only */@@ -52,133 +44,209 @@/* Both */.pulse-both .badge,.pulse-both .dot-badge{animation:badge-scale var(--pulse-dur) ease-in-out infinite}.pulse-both .badge::after,.pulse-both .dot-badge::after{content:'';position:absolute;inset:-4px;border-radius:50%;background:var(--badge-color);opacity:.4;animation:halo-grow var(--pulse-dur) ease-out infinite}- /* Fade mode */+ /* Stops after three pulses */.fade-mode .badge,.fade-mode .dot-badge,.fade-mode .badge::after,.fade-mode .dot-badge::after{animation-iteration-count:3!important}/* Status dot (online) */.status-dot{position:absolute;bottom:-2px;right:-2px;width:16px;height:16px;border-radius:50%;background:#56d364;border:2px solid var(--bg);animation:badge-scale var(--pulse-dur) ease-in-out infinite}- /* 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}- .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}- input[type=color]{border:none;background:none;width:44px;height:44px;cursor:pointer;border-radius:4px;padding:0}- @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:auto}.stage{width:100%;height:auto;min-height:360px}.icon-row{gap:20px}}- @media(prefers-reduced-motion:reduce){.badge,.dot-badge,.status-dot,.badge::after,.dot-badge::after{animation:none!important}.badge::after,.dot-badge::after{display:none}}</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=4">+ <script src="../../../assets/js/demo-page.js?v=4" 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="../form-field-morph/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../tooltip-reveal/" 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/04-micro-interactions/badge-pulse/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>-<header>- <h1>Notification Badge Pulse</h1>- <p>Dot on icon pulses to draw peripheral attention — scale, halo, or both.</p>-</header>-<div class="layout">- <div class="stage">- <div class="icon-row" id="icon-row">- <div class="icon-wrap">- <div class="icon-btn pulse-scale" id="ic0" aria-label="Notifications, 3 new" role="button" tabindex="0">- 🔔- <div class="badge" id="badge0">3</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="../form-field-morph/" rel="prev" aria-label="Previous: Form Field 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>Form Field Morph</span></a><a href="../tooltip-reveal/" rel="next" aria-label="Next: Tooltip Reveal"><span><span class="hb-dir">Next: </span>Tooltip Reveal</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">04.15 · Micro-Interactions</p>+ <h1>Notification Badge Pulse</h1>+ <p class="hb-lede">A badge on an icon pulses to catch the eye. Best for unread messages.</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, or click an icon to clear its badge; Reset brings the badges back.</p></div>+ </div>+ <div class="stage hb-dots">+ <div class="icon-row" id="icon-row">+ <div class="icon-wrap">+ <div class="icon-btn pulse-scale" id="ic0" aria-label="Notifications, 3 new" role="button" tabindex="0">+ 🔔+ <div class="badge" id="badge0">3</div>+ </div>+ <div class="icon-label">Number</div>+ </div>+ <div class="icon-wrap">+ <div class="icon-btn pulse-scale" id="ic1" aria-label="Inbox, new messages" role="button" tabindex="0">+ 📥+ <div class="dot-badge" id="badge1"></div>+ </div>+ <div class="icon-label">Dot</div>+ </div>+ <div class="icon-wrap">+ <div class="icon-btn icon-round" id="ic2" aria-label="Profile, online" role="button" tabindex="0">+ 🧑+ <div class="status-dot" id="badge2"></div>+ </div>+ <div class="icon-label">Online</div>+ </div>+ </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>+ <button class="hb-play" type="button" id="btn-reset" data-hb-reset><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>Reset</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="style-lbl">Pulse style</p>+ <div class="seg" id="style-seg" role="group" aria-labelledby="style-lbl">+ <button type="button" data-style="pulse-scale" class="on" aria-pressed="true">Grow</button>+ <button type="button" data-style="pulse-halo" aria-pressed="false">Ring</button>+ <button type="button" data-style="pulse-both" aria-pressed="false">Both</button></div>- <div class="icon-label">Bell<br>numbered</div>+ <p class="hb-hint">Grow stays contained; Ring spreads a soft halo.</p></div>- <div class="icon-wrap">- <div class="icon-btn pulse-scale" id="ic1" aria-label="Inbox, new messages" role="button" tabindex="0">- 📥- <div class="dot-badge" id="badge1"></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="2400" aria-pressed="false">Slow</button>+ <button type="button" data-ms="1500" class="on" aria-pressed="true">Normal</button>+ <button type="button" data-ms="900" aria-pressed="false">Fast</button></div>- <div class="icon-label">Inbox<br>dot</div>+ <p class="hb-hint">Fast feels urgent; slow is easy to miss.</p></div>- <div class="icon-wrap">- <div class="icon-btn" id="ic2" aria-label="Profile, online" role="button" tabindex="0" style="border-radius:50%;width:64px;height:64px;font-size:28px">- 🧑- <div class="status-dot" id="badge2"></div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="grow-lbl">How much it grows</p>+ <div class="seg" id="grow-seg" role="group" aria-labelledby="grow-lbl">+ <button type="button" data-scale="1.15" aria-pressed="false">Slightly</button>+ <button type="button" data-scale="1.3" class="on" aria-pressed="true">Medium</button>+ <button type="button" data-scale="1.5" aria-pressed="false">A lot</button></div>- <div class="icon-label">Avatar<br>online</div>+ <p class="hb-hint">Much bigger than a third starts to feel alarming.</p></div></div>- </div>- <aside>- <p class="note">A subtle 1.15× scale at 1.5s intervals catches peripheral vision without causing anxiety. Too fast = frantic; too slow = imperceptible.</p>- <div class="lbl">Pulse Duration</div>- <div class="sr"><input type="range" id="dur-sl" min="800" max="3000" value="1500" step="100"><span class="sv" id="dur-v">1.5s</span></div>- <div class="lbl">Scale Amount</div>- <div class="sr"><input type="range" id="scale-sl" min="110" max="160" value="130" step="5"><span class="sv" id="scale-v">1.30</span></div>- <div class="lbl">Pulse Style</div>- <select id="style-sel">- <option value="pulse-scale" selected>Scale only</option>- <option value="pulse-halo">Halo expand</option>- <option value="pulse-both">Scale + Halo</option>- </select>- <div class="lbl">Badge Color</div>- <input type="color" id="color-pick" value="#f85149" aria-label="Badge color">- <label class="tog"><input type="checkbox" id="fade-tog"><span>Fade after attention (3 pulses)</span></label>- <div class="div"></div>- <p style="font-size:10px;color:var(--ui-muted)">Click an icon to dismiss its badge.</p>- </aside>-</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-switch-row"><span>Stops after three pulses</span><input class="hb-switch" type="checkbox" role="switch" id="fade-tog" autocomplete="off"></label>+ <p class="hb-hint">Pulses three times to be noticed, then rests.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="color-lbl">Badge color</p>+ <div class="swatches" id="color-sw" role="group" aria-labelledby="color-lbl">+ <button type="button" class="on" aria-pressed="true" aria-label="Red" data-c="#f85149" style="background:#f85149"></button>+ <button type="button" aria-pressed="false" aria-label="Pink" data-c="#ff6f8b" style="background:#ff6f8b"></button>+ <button type="button" aria-pressed="false" aria-label="Blue" data-c="#58a6ff" style="background:#58a6ff"></button>+ <button type="button" aria-pressed="false" aria-label="Purple" data-c="#d2a8ff" style="background:#d2a8ff"></button>+ <button type="button" aria-pressed="false" aria-label="Orange" data-c="#ffa657" style="background:#ffa657"></button>+ </div>+ <p class="hb-hint">Red reads as new and urgent.</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 pulsing notification badge to [the icon that has something new, such as a bell or an inbox]. Place a small colored dot or number on the icon's corner and let it pulse, growing and settling back or sending a soft ring outward, so it catches the eye without demanding attention. Give the badge a thin border in the background color so it seems to float above the icon. Remove the badge once the visitor has opened what it points to, and when the settings ask for it, stop the pulse after three beats. If the visitor has reduced motion turned on, keep the badge 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>Notification bells</li><li>Inboxes</li><li>Chat icons</li><li>Online status</li></ul>+ <h3>Avoid on</h3>+ <ul class="hb-tags hb-avoid"><li>Items already seen</li><li>Many icons at once</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 icons=document.querySelectorAll('.icon-btn');- const badges=document.querySelectorAll('.badge,.dot-badge,.status-dot');- let currentStyle='pulse-scale';+ const stage=document.querySelector('.stage');+ const vars=document.documentElement.style;+ const icons=[...document.querySelectorAll('.icon-btn')];+ let currentStyle='pulse-scale',pulseMs=1500;+ // Taking the pulse class off, reading the layout and putting it back starts the bell's and the inbox's animations again+ // from their first frame (on a paused stage they wait there until Play). The online dot has no pulse class and keeps going.function applyStyle(){icons.forEach((ic,i)=>{- if(i===2)return; // status dot always pulses+ if(i===2)return;ic.classList.remove('pulse-scale','pulse-halo','pulse-both');- void ic.offsetWidth; // reflow so re-adding the same class restarts the animation+ void ic.offsetWidth;ic.classList.add(currentStyle);});}- icons.forEach((ic,i)=>{+ // Clicking an icon, or pressing Enter or Space on it, clears its badge; Reset shows every badge again at once.+ icons.forEach(ic=>{const dismiss=()=>{const b=ic.querySelector('.badge,.dot-badge');- if(b){b.style.display='none';}+ if(b)b.style.display='none';};ic.addEventListener('click',dismiss);- ic.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();dismiss();}});- });-- document.getElementById('dur-sl').addEventListener('input',e=>{- document.getElementById('dur-v').textContent=(e.target.value/1000).toFixed(1)+'s';- document.documentElement.style.setProperty('--pulse-dur',e.target.value+'ms');+ ic.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();dismiss()}});});- document.getElementById('scale-sl').addEventListener('input',e=>{- const v=(e.target.value/100).toFixed(2);- document.getElementById('scale-v').textContent=v;- document.documentElement.style.setProperty('--pulse-scale',v);+ document.getElementById('btn-reset').addEventListener('click',()=>{+ document.querySelectorAll('.badge,.dot-badge').forEach(b=>{b.style.display=''});+ applyStyle();});- document.getElementById('style-sel').addEventListener('change',e=>{- currentStyle=e.target.value;applyStyle();- });- document.getElementById('color-pick').addEventListener('input',e=>{- document.documentElement.style.setProperty('--badge-color',e.target.value);++ 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('style-seg',d=>{currentStyle=d.style;applyStyle()});+ // A new --pulse-dur keeps the time already played, so every pulse would jump to another point of its cycle.+ // Scaling each animation's time by the same factor as its length keeps the pulses where they are, moving or paused.+ choices('speed-seg',d=>{+ const next=+d.ms;+ stage.getAnimations({subtree:true}).forEach(a=>{if(a.animationName&&a.currentTime!=null)a.currentTime=a.currentTime*next/pulseMs});+ pulseMs=next;+ vars.setProperty('--pulse-dur',next+'ms');});+ choices('grow-seg',d=>{vars.setProperty('--pulse-scale',d.scale)});+ choices('color-sw',d=>{vars.setProperty('--badge-color',d.c)});document.getElementById('fade-tog').addEventListener('change',e=>{icons.forEach(ic=>ic.classList.toggle('fade-mode',e.target.checked));- if(e.target.checked)applyStyle(); // restart so the 3-pulse run is visible each time+ applyStyle();});</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 6e90b8dc..c82f6a5a 100644--- a/index.html+++ b/index.html@@ -965,7 +965,7 @@ const CATS=[['progress-animation','Progress Animation','A bar, a ring and steps fill up to show progress. Best for uploads.'],['checkmark-draw','Checkmark Draw','A tick draws itself in a circle once a task succeeds. Best for forms.'],['form-field-morph','Form Field Morph','The label moves up out of the way as you type. Best for sign-up forms.'],- ['badge-pulse','Notification Badge Pulse','Dot on icon pulses to draw peripheral attention — scale, halo, or both.'],+ ['badge-pulse','Notification Badge Pulse','A badge on an icon pulses to catch the eye. Best for unread messages.'],['tooltip-reveal','Tooltip Reveal','Info box fades in after a 300ms delay — long enough to avoid triggering on mouse pass-through.'],['drawer-slide','Drawer / Panel Slide','Off-canvas panel slides from edge — ease-out open, ease-in close. Backdrop dismisses.'],['modal-expand','Modal Expand','Modal scales from the trigger button\'s position — transform-origin set to where you clicked.'],