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 Curtain Reveal to the guided-steps page
matind415916ac719
diff --git a/animations/02-entrance-and-exit/curtain-reveal/README.md b/animations/02-entrance-and-exit/curtain-reveal/README.mdindex 72499e6e..5d30abd5 100644--- a/animations/02-entrance-and-exit/curtain-reveal/README.md+++ b/animations/02-entrance-and-exit/curtain-reveal/README.md@@ -31,27 +31,26 @@ setTimeout(() => { // stage B: pause}, dur);```-The `101%` (rather than `100%`) guarantees the bar clears the edge completely with no sub-pixel seam.+Both sides uses two half-width panels that start off opposite edges, meet in the middle and go back. The `101%` (rather than `100%`) guarantees the bar clears the edge completely with no sub-pixel seam.## Key parameters| Parameter | Default | Effect ||-----------|---------|--------|-| Curtain speed | 500ms | Time for one pass; the whole reveal takes about two passes plus the pause |-| Pause between | 300ms | The beat where the panel covers everything; it is what makes the change register |-| Direction | Left to right | Which way the panel travels, across or up and down |-| Two curtains (split) | off | Two panels meet in the middle, then part |-| Curtain color | Dark | Strong contrast with the content makes the reveal more dramatic |+| Comes in from | Left | Which way the panel travels; Both sides sends two panels that meet in the middle, then part |+| Speed | Normal | Time for one pass: slow is 800ms, normal 500ms and fast 300ms; the whole reveal takes about two passes plus the pause |+| Pause while covered | Short | How long the panel covers everything: none, short (300ms) or long (800ms); the pause is what makes the change register |+| Curtain color | Dark | The panel's color; strong contrast with the content makes the reveal more dramatic |## Production notes- **Overshoot the edge with `101%`.** Ending an exit exactly at `100%` can leave a 1px sliver on fractional-DPI displays; the extra percent is the standard fix.- **The content behind is never hidden from the DOM** — only visually covered. If the reveal gates *loading*, swap the underlying content during the `pause` stage while the bar hides the switch, so users never see the change happen.-- **Guard against re-entry.** The demo uses a `busy` flag so a second trigger can't start a new sequence mid-animation and desync the timers — important for any multi-stage, timer-driven effect.-- **Reduced motion:** the demo disables the curtain transitions under `prefers-reduced-motion`; consider revealing the content immediately instead of playing the cover/uncover theatre for those users.+- **Guard against re-entry.** Each play clears the timers of the one before, so a second trigger can't start a new sequence mid-animation and desync the stages — important for any multi-stage, timer-driven effect.+- **Reduced motion:** a play skips the cover-and-uncover pass entirely under `prefers-reduced-motion` — the content simply stays visible the whole time, so the panel never flashes across it.- **Library equivalents:** GSAP timelines are the natural fit — `.to(curtain, { x: 0 }).to(curtain, { x: '101%' }, '+=0.3')` chains the stages with a built-in pause; Framer Motion sequences variants via `AnimatePresence`; Motion One's `animate` accepts a keyframe array with `offset` and `delay` to script the three beats.## See also-- [Clip-Path Reveal](../clip-path-reveal/) — uncover by masking, without an opaque moving bar-- [Slide Up Reveal](../slide-up-reveal/) — a single clipped line rising into view-- [Slide In](../slide-in/) — the plain translate this dramatizes-- [Split Text Reveal](../split-text-reveal/) — staggered per-unit reveals for text+- [Clip-Path Reveal](../clip-path-reveal/) — a shape uncovers it, with no panel+- [Slide Up Reveal](../slide-up-reveal/) — text rises from behind an invisible edge+- [Slide In](../slide-in/) — travels into place from one edge+- [Split Text Reveal](../split-text-reveal/) — text appears piece by piecediff --git a/animations/02-entrance-and-exit/curtain-reveal/index.html b/animations/02-entrance-and-exit/curtain-reveal/index.htmlindex 7849f8b6..cef0fa1b 100644--- a/animations/02-entrance-and-exit/curtain-reveal/index.html+++ b/animations/02-entrance-and-exit/curtain-reveal/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Curtain Reveal — Animation Handbook</title>- <meta name="description" content="A colored bar slides over content then off the other side — the reveal is hidden then exposed.">+ <meta name="description" content="A colored panel covers it, then slides away. Best for intros and logos."><link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/02-entrance-and-exit/curtain-reveal/"><link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">@@ -12,157 +12,168 @@<meta property="og:type" content="article"><meta property="og:site_name" content="Animation Handbook"><meta property="og:title" content="Curtain Reveal — Animation Handbook">- <meta property="og:description" content="A colored bar slides over content then off the other side — the reveal is hidden then exposed.">+ <meta property="og:description" content="A colored panel covers it, then slides away. Best for intros and logos."><meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/02-entrance-and-exit/curtain-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="Curtain Reveal — Animation Handbook">- <meta name="twitter:description" content="A colored bar slides over content then off the other side — the reveal is hidden then exposed.">+ <meta name="twitter:description" content="A colored panel covers it, then slides away. Best for intros and logos."><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": "Curtain Reveal", "name": "Curtain Reveal", "description": "A colored bar slides over content then off the other side — the reveal is hidden then exposed.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/02-entrance-and-exit/curtain-reveal/", "inLanguage": "en", "articleSection": "Entrance & Exit", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Entrance & Exit, Curtain Reveal"}</script>+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Curtain Reveal", "name": "Curtain Reveal", "description": "A colored panel covers it, then slides away. Best for intros and logos.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/02-entrance-and-exit/curtain-reveal/", "inLanguage": "en", "articleSection": "Entrance & Exit", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Entrance & Exit, Curtain Reveal"}</script><style>- :root{--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#5fd88a;--ui-text:#f4f4f2;--ui-muted:#77777e;--stage-h:620px;--dur:500ms;--ease:cubic-bezier(.2,.7,.3,1);--curtain-color:#111827;--pause:300ms}+ :root{--ui-accent:#5fd88a;--ui-muted:#77777e;--dur:500ms;--ease:cubic-bezier(.2,.7,.3,1);--curtain-color:#111827}*,*::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:#0a0f18;display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative}- /* Content */- .content{display:flex;flex-direction:column;align-items:center;gap:16px;text-align:center;padding:24px;z-index:1}+ .stage{display:flex;align-items:center;justify-content:center;overflow:hidden;background:#0a0f18;position:relative}+ .content{display:flex;flex-direction:column;align-items:center;gap:16px;text-align:center;padding:24px;z-index:1;font-family:monospace}.content-badge{font-size:10px;text-transform:uppercase;letter-spacing:3px;color:var(--ui-accent);opacity:.7}.content-title{font-size:clamp(24px,4vw,42px);font-weight:bold;line-height:1.1}.content-sub{font-size:12px;color:var(--ui-muted);max-width:260px;line-height:1.6}- /* Curtains *//* --from / --to are the off-stage positions; JS sets them per direction */.curtain,.curtain-b{position:absolute;background:var(--curtain-color);z-index:2;transition:transform var(--dur) var(--ease);transform:var(--from)}- /* Horizontal */.curtain[data-axis=h]{inset:0 auto 0 0;width:100%;--from:translateX(-101%);--to:translateX(101%)}- /* Vertical */.curtain[data-axis=v]{inset:0 0 auto 0;height:100%;--from:translateY(-101%);--to:translateY(101%)}- /* Two-curtain halves */.curtain-b[data-axis=h]{inset:0 0 0 auto;width:50%;--from:translateX(101%);--to:translateX(101%)}.curtain[data-axis=h].twin{width:50%}.curtain.c-in,.curtain-b.c-in{transform:translate(0,0)}.curtain.c-out,.curtain-b.c-out{transform:var(--to)}- /* Timeline */- .tl{display:flex;gap:4px;align-items:center;position:absolute;bottom:16px;left:50%;transform:translateX(-50%);pointer-events:none}- .tl-seg{position:relative;height:4px;border-radius:2px;width:48px;background:var(--ui-border);transition:background .2s}- .tl-seg.active{background:var(--ui-accent)}- .tl-label{font-size:8px;color:var(--ui-muted);position:absolute;bottom:-14px;white-space:nowrap}@media(prefers-reduced-motion:reduce){.curtain,.curtain-b{transition:none!important}}- 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:38px;text-align:right;color:var(--ui-text)}- .seg{display:flex;gap:3px;flex-wrap:wrap}- .seg button{flex:1;background:none;border:1px solid var(--ui-border);color:var(--ui-muted);font-family:monospace;font-size:9px;padding:8px 4px;border-radius:4px;cursor:pointer;min-height:44px}- .seg button.on{border-color:var(--ui-accent);color:var(--ui-accent);background:rgba(95,216,138,.12)}- .swatches{display:flex;gap:5px}- .swatch{flex:1;min-width:0;min-height:44px;padding:9px 3px;background:var(--c);background-clip:content-box;border-radius:4px;cursor:pointer;border:2px solid transparent}- .swatch.on{border-color:var(--ui-text)}- .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}- .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}- .btn-row{display:flex;gap:6px}- button.act{flex:1;background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 6px;border-radius:4px;cursor:pointer;min-height:44px}- button.act.pri{border-color:var(--ui-accent);color:var(--ui-accent)}- @media(hover:hover){button.act:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}- @media(max-width:600px){.layout{flex-direction:column}.stage{flex:none;width:100%}aside{width:100%}:root{--stage-h:480px}}</style>-<link rel="stylesheet" href="../../../assets/css/handbook.css">-<script src="../../../assets/js/handbook.js" defer></script>+ <link rel="stylesheet" href="../../../assets/css/demo-page.css">+ <script src="../../../assets/js/demo-page.js" defer></script></head>-<body class="hb">-<nav class="hb-bar" aria-label="Animation Handbook"><a class="hb-home" href="../../../">← <span>Animation Handbook</span></a><span class="hb-pager"><a href="../clip-path-reveal/" rel="prev" aria-label="Previous: Clip-Path Reveal">‹ <span class="hb-name">Clip-Path Reveal</span></a><a href="../split-text-reveal/" rel="next" aria-label="Next: Split Text Reveal"><span class="hb-name">Split Text Reveal</span> ›</a></span></nav>-<main class="hb-view">- <div class="stage" id="stage">- <div class="curtain" id="curtain" data-axis="h"></div>- <div class="curtain-b" id="curtain-b" data-axis="h" style="display:none"></div>- <div class="content">- <div class="content-badge">Curtain Reveal</div>- <div class="content-title">Unveiled</div>- <div class="content-sub">The reveal is hidden then exposed — your eye registers the change dramatically.</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="../clip-path-reveal/" rel="prev" aria-label="Previous: Clip-Path Reveal"><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>Clip-Path Reveal</span></a><a href="../split-text-reveal/" rel="next" aria-label="Next: Split Text Reveal"><span><span class="hb-dir">Next: </span>Split Text 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">02.06 · Entrance & Exit</p>+ <h1>Curtain Reveal</h1>+ <p class="hb-lede">A colored panel covers it, then slides away. Best for intros and logos.</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="tl">- <div class="tl-seg" id="tl0"><span class="tl-label" style="left:0">enter</span></div>- <div class="tl-seg" id="tl1"><span class="tl-label" style="left:0">pause</span></div>- <div class="tl-seg" id="tl2"><span class="tl-label" style="left:0">exit</span></div>+ <div class="stage hb-dots">+ <div class="curtain" id="curtain" data-axis="h"></div>+ <div class="curtain-b" id="curtain-b" data-axis="h" style="display:none"></div>+ <div class="content">+ <div class="content-badge">Curtain Reveal</div>+ <div class="content-title">Unveiled</div>+ <div class="content-sub">The reveal is hidden then exposed — your eye registers the change dramatically.</div>+ </div></div>- </div>- <aside class="hb-side">- <header class="hb-head">- <p class="hb-cat">02.06 · Entrance & Exit</p>- <h1>Curtain Reveal</h1>- <p class="hb-lede">A colored panel covers the content, then slides away to reveal it.</p>- </header>- <section class="hb-settings" aria-label="Settings">- <h2 class="hb-label">Settings</h2>- <div class="lbl">State</div>- <div class="kv"><span>Status</span><span class="v" id="st">idle</span></div>- <div class="div"></div>- <div class="lbl">Curtain color</div>- <div class="swatches" id="swatches">- <div class="swatch on" data-c="#111827" style="--c:#111827" tabindex="0" role="button" aria-label="Dark"></div>- <div class="swatch" data-c="#1e3a5f" style="--c:#1e3a5f" tabindex="0" role="button" aria-label="Ink blue"></div>- <div class="swatch" data-c="#5c1a1a" style="--c:#5c1a1a" tabindex="0" role="button" aria-label="Warm red"></div>- <div class="swatch" data-c="#f0ede8" style="--c:#f0ede8" tabindex="0" role="button" aria-label="Off-white"></div>- <div class="swatch" data-c="#8a6e14" style="--c:#8a6e14" tabindex="0" role="button" aria-label="Gold"></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><span>Loop</span></label>+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="slow-tog" data-hb-slowmo><span>Slow motion</span></label></div>- <div class="lbl">Direction</div>- <div class="seg" id="dir-seg">- <button data-ax="h" data-dir="ltr" class="on" aria-label="Left to right">→ L→R</button>- <button data-ax="h" data-dir="rtl" aria-label="Right to left">← R→L</button>- <button data-ax="v" data-dir="ttb" aria-label="Top to bottom">↓ Top</button>- <button data-ax="v" data-dir="btt" aria-label="Bottom to top">↑ Bot</button>+ </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><div class="lbl" id="dur-lbl">Curtain speed</div>- <div class="sr"><input type="range" id="dur-sl" aria-labelledby="dur-lbl" min="100" max="1500" value="500" step="50"><span class="sv" id="dur-v">500ms</span></div>+ <div class="hb-settings">+ <div class="hb-setting">+ <p class="hb-setting-name" id="from-lbl">Comes in from</p>+ <div class="seg" id="from-seg" role="group" aria-labelledby="from-lbl">+ <button type="button" data-axis="h" data-dir="ltr" class="on" aria-pressed="true">Left</button>+ <button type="button" data-axis="h" data-dir="rtl" aria-pressed="false">Right</button>+ <button type="button" data-axis="v" data-dir="ttb" aria-pressed="false">Top</button>+ <button type="button" data-axis="v" data-dir="btt" aria-pressed="false">Bottom</button>+ <button type="button" data-axis="h" data-dir="ltr" data-twin="1" aria-pressed="false">Both sides</button>+ </div>+ <p class="hb-hint">Both sides sends two panels that meet in the middle.</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="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 fast the curtain slides across.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="pause-lbl">Pause while covered</p>+ <div class="seg" id="pause-seg" role="group" aria-labelledby="pause-lbl">+ <button type="button" data-pause="0" aria-pressed="false">None</button>+ <button type="button" data-pause="300" class="on" aria-pressed="true">Short</button>+ <button type="button" data-pause="800" aria-pressed="false">Long</button>+ </div>+ <p class="hb-hint">The pause is what makes the change register.</p>+ </div></div>- <div><div class="lbl" id="pause-lbl">Pause between</div>- <div class="sr"><input type="range" id="pause-sl" aria-labelledby="pause-lbl" min="0" max="1200" value="300" step="50"><span class="sv" id="pause-v">300ms</span></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="color-lbl">Curtain color</p>+ <div class="swatches" id="color-sw" role="group" aria-labelledby="color-lbl">+ <button type="button" class="on" aria-pressed="true" aria-label="Dark" data-c="#111827" style="background:#111827"></button>+ <button type="button" aria-pressed="false" aria-label="Ink blue" data-c="#1e3a5f" style="background:#1e3a5f"></button>+ <button type="button" aria-pressed="false" aria-label="Warm red" data-c="#5c1a1a" style="background:#5c1a1a"></button>+ <button type="button" aria-pressed="false" aria-label="Off-white" data-c="#f0ede8" style="background:#f0ede8"></button>+ <button type="button" aria-pressed="false" aria-label="Gold" data-c="#8a6e14" style="background:#8a6e14"></button>+ </div>+ <p class="hb-hint">Strong contrast with the content feels more dramatic.</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>- <label class="tog" for="twin-tog"><input type="checkbox" id="twin-tog"><span>Two curtains (split)</span></label>- <div class="div"></div>- <label class="tog" for="loop-tog"><input type="checkbox" id="loop-tog" data-hb-skip data-hb-loop><span>Auto-loop</span></label>- <div class="btn-row">- <button class="act pri" id="btn-play" data-hb-replay aria-label="Play curtain reveal">Play reveal</button>- <button class="act" id="btn-rst" data-hb-reset aria-label="Reset">Reset</button>+ <div class="hb-card">+ <p class="hb-prompt">Add a curtain reveal to [the content you want to reveal]. A solid colored panel should slide across and cover the content completely, hold for the pause given in the settings, then keep going and slide off the far side, leaving the content visible. The pause is what makes the change register. When the panels come in from both sides, two panels meet in the middle, then part. Pick a panel color that contrasts strongly with the content. Move the panels rather than resizing them so the motion stays smooth. If the visitor has reduced motion turned on, show the content without the curtain. 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>- </section>- <div class="hb-take">- <section class="hb-prompt-box" aria-labelledby="hb-prompt-title">- <h2 class="hb-label" id="hb-prompt-title">Prompt</h2>- <p class="hb-prompt">Add a curtain reveal to [the content you want to reveal]. A solid colored panel should slide across and cover the content completely, pause for a beat, then keep going and slide off the far side, leaving the content visible. The pause is what makes the change register, so keep it. In split mode, two panels come in from opposite sides, meet in the middle, then part. Pick a panel color that contrasts strongly with the content. Move the panels rather than resizing them so the motion stays smooth. If the visitor has reduced motion turned on, show the content without the curtain. Match the settings listed below.</p>- </section>+ <div class="hb-fit">+ <h2>Good for</h2>+ <ul class="hb-tags hb-good"><li>Page intros</li><li>Logos</li><li>Section changes</li><li>Portfolio pieces</li></ul>+ <h3>Avoid on</h3>+ <ul class="hb-tags hb-avoid"><li>Buttons and menus</li><li>Things shown often</li></ul></div>- </aside>+ </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 curtain=document.getElementById('curtain'),curtainB=document.getElementById('curtain-b');- const stEl=document.getElementById('st'),loopTog=document.getElementById('loop-tog');- const durSl=document.getElementById('dur-sl'),durV=document.getElementById('dur-v');- const pauseSl=document.getElementById('pause-sl'),pauseV=document.getElementById('pause-v');- const twinTog=document.getElementById('twin-tog');+ 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 dur=500,pause=300,axis='h',dirMode='ltr',twin=false,looping=false,loopTimer=null,busy=false;-- function setTL(i){document.querySelectorAll('.tl-seg').forEach((s,j)=>s.classList.toggle('active',j===i))}- // Snap both curtains back off-stage without animating (otherwise the bar would- // slide from its exit side back to its entry side, or enter from the wrong edge).- function clearCurtains(setup){- [curtain,curtainB].forEach(c=>{c.style.transition='none';c.className=c.id==='curtain'?'curtain':'curtain-b';c.dataset.axis=axis;c.style.removeProperty('--from');c.style.removeProperty('--to')});- curtainB.style.display=(twin&&axis==='h')?'block':'none';- if(setup)setup();- void curtain.offsetWidth;- [curtain,curtainB].forEach(c=>c.style.removeProperty('transition'));- }+ let axis='h',dirMode='ltr',twin=false,ms=500,pause=300,timers=[];+ function dur(){return slowTog.checked?ms*3:ms}+ function pauseDur(){return slowTog.checked?pause*3:pause}function getInDir(){if(axis==='h')return dirMode==='ltr'?'translateX(-101%)':'translateX(101%)';return dirMode==='ttb'?'translateY(-101%)':'translateY(101%)';@@ -171,61 +182,56 @@if(axis==='h')return dirMode==='ltr'?'translateX(101%)':'translateX(-101%)';return dirMode==='ttb'?'translateY(101%)':'translateY(-101%)';}-- function play(){- if(busy)return;busy=true;- clearCurtains(()=>{- if(twin&&axis==='h'){- curtain.classList.add('twin'); // halves use the CSS defaults: left from -101%, right from 101%- } else {- curtain.style.setProperty('--from',getInDir());curtain.style.setProperty('--to',getOutDir());- }+ function later(fn,wait){timers.push(setTimeout(fn,wait))}+ // Snap both curtains back off-stage without animating (otherwise the bar would slide from its+ // exit side back to its entry side, or enter from the wrong edge), and set this play's speed.+ function clearCurtains(){+ vars.setProperty('--dur',dur()+'ms');+ [curtain,curtainB].forEach(c=>{+ c.style.setProperty('transition','none','important');+ c.className=c.id==='curtain'?'curtain':'curtain-b';+ c.dataset.axis=axis;+ c.style.removeProperty('--from');c.style.removeProperty('--to');});- stEl.textContent='entering';setTL(0);- // Stage A: curtain enters- if(twin&&axis==='h'){curtain.classList.add('c-in');curtainB.classList.add('c-in');}+ curtainB.style.display=(twin&&axis==='h')?'block':'none';+ if(twin&&axis==='h'){curtain.classList.add('twin')}+ else{curtain.style.setProperty('--from',getInDir());curtain.style.setProperty('--to',getOutDir())}+ void curtain.offsetWidth;+ [curtain,curtainB].forEach(c=>c.style.removeProperty('transition'));+ }+ // One play covers the content, holds while covered, then uncovers it. While Loop is on it then+ // waits and plays again; switching Loop off lets the content stay revealed. Slow motion stretches+ // both passes and the pause, not the 500ms wait between cycles. Reduced motion skips the pass+ // entirely so the panel never flashes across the content.+ function cycle(){+ clearCurtains();+ if(!motionOk)return;+ if(twin&&axis==='h'){curtain.classList.add('c-in');curtainB.classList.add('c-in')}else curtain.classList.add('c-in');-- loopTimer=setTimeout(()=>{- stEl.textContent='pause';setTL(1);- loopTimer=setTimeout(()=>{- stEl.textContent='exiting';setTL(2);- if(twin&&axis==='h'){curtain.classList.remove('c-in');curtainB.classList.remove('c-in');}- else{curtain.classList.remove('c-in');curtain.classList.add('c-out');}- loopTimer=setTimeout(()=>{- stEl.textContent='revealed';setTL(-1);busy=false;- if(looping)loopTimer=setTimeout(play,500);- },dur);- },pause);- },dur);+ later(()=>{+ later(()=>{+ if(twin&&axis==='h'){curtain.classList.remove('c-in');curtainB.classList.remove('c-in')}+ else{curtain.classList.remove('c-in');curtain.classList.add('c-out')}+ later(()=>{if(loopTog.checked)later(cycle,500)},dur());+ },pauseDur());+ },dur());}- function stopLoop(){looping=false;clearTimeout(loopTimer);loopTog.checked=false;busy=false}+ function play(){timers.forEach(clearTimeout);timers=[];cycle()}- document.getElementById('btn-play').addEventListener('click',()=>{stopLoop();play()});- document.getElementById('btn-rst').addEventListener('click',()=>{- stopLoop();clearCurtains();stEl.textContent='idle';setTL(-1);- });- loopTog.addEventListener('change',()=>{- looping=loopTog.checked;- if(looping&&motionOk){if(!busy)play()}- else if(looping)stopLoop(); // reduced motion: never auto-play- else if(!busy)clearTimeout(loopTimer); // let a running cycle finish, just don't queue another- });- document.querySelectorAll('#dir-seg button').forEach(b=>b.addEventListener('click',()=>{- document.querySelectorAll('#dir-seg button').forEach(x=>x.classList.remove('on'));b.classList.add('on');- axis=b.dataset.ax;dirMode=b.dataset.dir;if(!busy)clearCurtains();- }));- document.querySelectorAll('.swatch').forEach(s=>{- const pick=()=>{- document.querySelectorAll('.swatch').forEach(x=>x.classList.remove('on'));s.classList.add('on');- document.documentElement.style.setProperty('--curtain-color',s.dataset.c);- };- s.addEventListener('click',pick);- s.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();pick()}});- });- durSl.addEventListener('input',()=>{dur=+durSl.value;durV.textContent=dur+'ms';document.documentElement.style.setProperty('--dur',dur+'ms')});- pauseSl.addEventListener('input',()=>{pause=+pauseSl.value;pauseV.textContent=pause+'ms'});- twinTog.addEventListener('change',()=>{twin=twinTog.checked;if(!busy)clearCurtains()});+ 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('from-seg',d=>{axis=d.axis;dirMode=d.dir;twin=d.twin==='1'});+ choices('speed-seg',d=>{ms=+d.ms});+ choices('pause-seg',d=>{pause=+d.pause});+ choices('color-sw',d=>{vars.setProperty('--curtain-color',d.c)});+ clearCurtains();</script></body></html>diff --git a/index.html b/index.htmlindex 60fb8a28..fb720796 100644--- a/index.html+++ b/index.html@@ -917,7 +917,7 @@ const CATS=[['slide-up-reveal','Slide Up Reveal','Text rises into view from behind an invisible edge. Best for headlines.'],['scale-in','Scale In / Zoom In','Grows from smaller to full size. Best for pop-ups and menus.'],['clip-path-reveal','Clip-Path Reveal','A growing shape uncovers it while it stays still. Best for images and banners.'],- ['curtain-reveal','Curtain Reveal','A colored bar slides over content then off the other side — the reveal is hidden then exposed.'],+ ['curtain-reveal','Curtain Reveal','A colored panel covers it, then slides away. Best for intros and logos.'],['split-text-reveal','Split Text Reveal','Text split into chars, words, or lines — each piece staggers with --index CSS transition-delay.'],['letter-by-letter-stagger','Letter-by-Letter Stagger','CSS transition-delay cascade per letter, or JS typewriter mode with a blinking cursor.'],['word-by-word-reveal','Word-by-Word Reveal','Words animate sequentially at 80–120ms per word — the readable stagger speed for taglines.'],