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 Zoom Into Image to the guided-steps page
matin24c77f3563bc
diff --git a/animations/01-scroll-based/zoom-into-image/README.md b/animations/01-scroll-based/zoom-into-image/README.mdindex 872ac1e5..0a07d8d3 100644--- a/animations/01-scroll-based/zoom-into-image/README.md+++ b/animations/01-scroll-based/zoom-into-image/README.md@@ -1,7 +1,7 @@# Zoom Into Image## What it is-A zoom-into-image effect expands a framed image outward to full-bleed as you scroll, reading as a camera flying into the picture — the "portal" effect. It's driven not by scaling the image but by animating a `clip-path: inset()` from a large inset down to zero, so a small windowed crop grows to fill the stage. This demo pins a nighttime landscape in a sticky frame and opens the clip as you scroll through a fixed budget, revealing a caption near the end.+Zoom into image starts with a small window onto a picture and opens it up to fill the screen as you scroll, as if you were flying into the picture. The picture itself never grows: more of it is simply uncovered, so it stays sharp. The window's rounded corners square off as it opens, and a caption fades in at the end.## When to use it- Hero-to-content transitions where a preview card should open into an immersive image@@ -18,9 +18,7 @@ const p = clamp((st - pinStart) / budget, 0, 1);const inset = lerp(startPct, 0, p); // 30% → 0% (crop opens)const radius = lerp(brStart, 0, p); // 16px → 0 (corners square off)-zoomImg.style.clipPath = portalTog.checked- ? `inset(${inset.toFixed(2)}% round ${radius.toFixed(1)}px)`- : `inset(${inset.toFixed(2)}%)`;+zoomImg.style.clipPath = `inset(${inset.toFixed(2)}% round ${radius.toFixed(1)}px)`;caption.style.opacity = p > 0.88 ? ((p - 0.88) / 0.12).toFixed(3) : '0';```@@ -30,11 +28,9 @@ Clipping rather than scaling is the crucial choice: `clip-path` reveals more of## Key parameters| Parameter | Default | Effect ||-----------|---------|--------|-| Start size (inset) | 30% | Inset on each side at the start; 30% shows a 40%-wide crop |-| Border radius start | 16px | Corner rounding of the initial frame; lerps to 0 as it opens |-| Progress `p` | derived | 0 at pin start, 1 when the scroll budget is exhausted |-| Section height | 2.5 × stage | Scroll distance the zoom occupies; taller = slower open |-| Caption fade window | last 12% (p > 0.88) | When the caption overlay begins appearing |+| Starting window | Medium | How much of the picture shows at first: small is a window a fifth of the box wide, medium two fifths and large three fifths |+| Corners | Rounded | How round the window's corners are at the start: square, 16px or 32px; they straighten as the window opens |+| Shows the starting frame | on | A faint outline stays where the window began, so you can see how far it has opened |## Production notes- **Clip, don't scale**: `clip-path: inset()` reveals real pixels, keeping the image sharp at every step. A `scale()` zoom enlarges a fixed render and softens. Use clipping when the whole image is present and you're uncovering it.@@ -45,7 +41,7 @@ Clipping rather than scaling is the crucial choice: `clip-path` reveals more of- **Library equivalents**: GSAP ScrollTrigger with `scrub` tweening `clipPath` is the direct equivalent and adds easing; Framer Motion animates the `clipPath` style off a `useTransform` of scroll progress in React.## See also-- [Sticky Section](../sticky-section/) — the pinning mechanic this builds on-- [Scrub Animation](../scrub-animation/) — binding a property continuously to scroll-- [Cover Card to Fixed Header](../cover-card-to-fixed-header/) — a card transforming as it's scrolled-- [Parallax Depth of Field](../parallax-depth-of-field/) — another depth-through-scroll illusion+- [Sticky Section](../sticky-section/) — the pinning this effect is built on+- [Scrub Animation](../scrub-animation/) — scroll position drives the movement, both ways+- [Cover Card to Fixed Header](../cover-card-to-fixed-header/) — a big cover changes shape as you scroll+- [Parallax Depth-of-Field](../parallax-depth-of-field/) — layers move and blur for depth as you scrolldiff --git a/animations/01-scroll-based/zoom-into-image/index.html b/animations/01-scroll-based/zoom-into-image/index.htmlindex d0156e05..4884bd2d 100644--- a/animations/01-scroll-based/zoom-into-image/index.html+++ b/animations/01-scroll-based/zoom-into-image/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Zoom Into Image — Animation Handbook</title>- <meta name="description" content="clip-path: inset() expands from a framed card to full-bleed as you scroll — the portal effect.">+ <meta name="description" content="A small window opens up to fill the box as you scroll. Best for hero images."><link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/01-scroll-based/zoom-into-image/"><link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">@@ -12,31 +12,22 @@<meta property="og:type" content="article"><meta property="og:site_name" content="Animation Handbook"><meta property="og:title" content="Zoom Into Image — Animation Handbook">- <meta property="og:description" content="clip-path: inset() expands from a framed card to full-bleed as you scroll — the portal effect.">+ <meta property="og:description" content="A small window opens up to fill the box as you scroll. Best for hero images."><meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/01-scroll-based/zoom-into-image/"><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="Zoom Into Image — Animation Handbook">- <meta name="twitter:description" content="clip-path: inset() expands from a framed card to full-bleed as you scroll — the portal effect.">+ <meta name="twitter:description" content="A small window opens up to fill the box as you scroll. Best for hero images."><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": "Zoom Into Image", "name": "Zoom Into Image", "description": "clip-path: inset() expands from a framed card to full-bleed as you scroll — the portal effect.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/01-scroll-based/zoom-into-image/", "inLanguage": "en", "articleSection": "Scroll-Based", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Scroll-Based, Zoom Into Image"}</script>+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Zoom Into Image", "name": "Zoom Into Image", "description": "A small window opens up to fill the box as you scroll. Best for hero images.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/01-scroll-based/zoom-into-image/", "inLanguage": "en", "articleSection": "Scroll-Based", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Scroll-Based, Zoom Into Image"}</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:#6ea8ff;--ui-text:#f4f4f2;--ui-muted:#77777e;--stage-h:600px;--start-pct:30;--br-start:16;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace}+ :root{--ui-accent:#6ea8ff;--br-start:16}*,*::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);overflow-y:scroll;scrollbar-width:none;border:1px solid var(--ui-border);border-radius:8px}+ .stage{position:relative;overflow-y:auto;scrollbar-width:none;container-type:size;background:#0b0b0d}.stage::-webkit-scrollbar{display:none}- .spacer{height:calc(var(--stage-h) * 0.6);display:flex;align-items:center;justify-content:center;font-size:11px;opacity:.25;letter-spacing:2px;text-align:center;padding:16px}- #zoom-section{height:calc(var(--stage-h) * 2.5);position:relative}- #zoom-sticky{position:sticky;top:0;height:var(--stage-h);display:flex;align-items:center;justify-content:center;overflow:hidden}+ .spacer{height:60cqh;display:flex;align-items:center;justify-content:center;padding:0 24px;font-size:13px;letter-spacing:.1em;color:#8a8a92;text-align:center}+ #zoom-section{height:250cqh;position:relative}+ #zoom-sticky{position:sticky;top:0;height:100cqh;display:flex;align-items:center;justify-content:center;overflow:hidden}/* Frame shown when showFrame is on */#frame{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;opacity:1;transition:opacity .4s}.frame-border{position:absolute;border:1px solid rgba(255,255,255,.15);border-radius:calc(var(--br-start) * 1px + 2px);pointer-events:none}@@ -45,157 +36,202 @@#zoom-img svg{width:100%;height:100%}/* Caption overlay */#caption{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;padding-bottom:40px;opacity:0;pointer-events:none;background:linear-gradient(transparent 60%,rgba(0,0,0,.6))}- #caption h2{font-size:clamp(18px,3vw,28px);font-weight:bold;letter-spacing:3px;text-transform:uppercase;text-align:center}- #caption p{font-size:11px;opacity:.6;margin-top:6px;letter-spacing:2px;text-transform:uppercase}- 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)}- .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}- 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%}- @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}- @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:460px}}+ #caption .cap-title{font-size:clamp(18px,3vw,28px);font-weight:700;letter-spacing:3px;text-transform:uppercase;text-align:center}+ #caption .cap-sub{font-size:11px;opacity:.6;margin-top:6px;letter-spacing:2px;text-transform:uppercase}@media(prefers-reduced-motion:reduce){#zoom-img{clip-path:inset(0% round 0px)!important}#caption{opacity:1!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=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="../section-wipe/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../scroll-image-sequence/" 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/01-scroll-based/zoom-into-image/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>-<header>- <h1>Zoom Into Image</h1>- <p>clip-path: inset() expands from a framed card to full-bleed as you scroll — the portal effect.</p>-</header>-<div class="layout">- <div class="stage" id="stage">- <div class="spacer">Scroll to enter the portal ↓</div>- <div id="zoom-section">- <div id="zoom-sticky">- <div id="zoom-img">- <svg viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice">- <defs>- <linearGradient id="sky-grad" x1="0" y1="0" x2="0" y2="1">- <stop offset="0%" stop-color="#060a18"/>- <stop offset="45%" stop-color="#0d1f3c"/>- <stop offset="100%" stop-color="#1a3050"/>- </linearGradient>- <linearGradient id="water-grad" x1="0" y1="0" x2="0" y2="1">- <stop offset="0%" stop-color="#0e2040"/>- <stop offset="100%" stop-color="#06111e"/>- </linearGradient>- <radialGradient id="moon-glow" cx="50%" cy="50%" r="50%">- <stop offset="0%" stop-color="#e8dca0" stop-opacity="0.4"/>- <stop offset="100%" stop-color="transparent"/>- </radialGradient>- </defs>- <!-- Sky -->- <rect width="800" height="420" fill="url(#sky-grad)"/>- <!-- Moon glow -->- <circle cx="600" cy="90" r="80" fill="url(#moon-glow)"/>- <!-- Moon -->- <circle cx="600" cy="90" r="28" fill="#e8dca0" opacity=".92"/>- <!-- Stars -->- <circle cx="80" cy="40" r="1.2" fill="white" opacity=".9"/>- <circle cx="220" cy="70" r="1" fill="white" opacity=".7"/>- <circle cx="340" cy="25" r="1.5" fill="white" opacity=".8"/>- <circle cx="460" cy="55" r="1" fill="white" opacity=".6"/>- <circle cx="150" cy="120" r="1" fill="white" opacity=".5"/>- <circle cx="700" cy="40" r="1.2" fill="white" opacity=".8"/>- <circle cx="760" cy="130" r="1" fill="white" opacity=".4"/>- <circle cx="50" cy="180" r="1" fill="white" opacity=".6"/>- <!-- Distant mountains -->- <polygon points="0,420 150,260 280,330 420,220 560,300 680,230 800,290 800,420" fill="#0a1a30" opacity=".9"/>- <!-- Near mountains -->- <polygon points="0,420 80,330 180,360 300,300 420,340 520,290 640,320 750,280 800,310 800,420" fill="#060e1c"/>- <!-- Reflection base -->- <rect y="420" width="800" height="180" fill="url(#water-grad)"/>- <!-- Water shimmer lines -->- <line x1="0" y1="440" x2="800" y2="440" stroke="rgba(255,255,255,.04)" stroke-width="1"/>- <line x1="0" y1="460" x2="800" y2="460" stroke="rgba(255,255,255,.03)" stroke-width="1"/>- <line x1="0" y1="485" x2="800" y2="485" stroke="rgba(255,255,255,.03)" stroke-width="1"/>- <!-- Moon reflection -->- <ellipse cx="600" cy="470" rx="18" ry="8" fill="#e8dca0" opacity=".25"/>- <ellipse cx="600" cy="500" rx="12" ry="4" fill="#e8dca0" opacity=".12"/>- </svg>+<body class="hb" data-hb-kind="scroll" 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="../section-wipe/" rel="prev" aria-label="Previous: Section Wipe"><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>Section Wipe</span></a><a href="../scroll-image-sequence/" rel="next" aria-label="Next: Scroll Image Sequence"><span><span class="hb-dir">Next: </span>Scroll Image Sequence</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">01.19 · Scroll-Based</p>+ <h1>Zoom Into Image</h1>+ <p class="hb-lede">A small window opens up to fill the box as you scroll. Best for hero images.</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">Scroll it</h2><p>Scroll inside the box, or press Play and it scrolls for you.</p></div>+ </div>+ <div class="stage" id="stage" tabindex="0" role="region" aria-label="A picture that opens up as you scroll">+ <div class="spacer">Scroll down ↓</div>+ <div id="zoom-section">+ <div id="zoom-sticky">+ <div id="zoom-img">+ <svg viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" role="img" aria-label="A lake under a full moon, between dark mountains">+ <defs>+ <linearGradient id="sky-grad" x1="0" y1="0" x2="0" y2="1">+ <stop offset="0%" stop-color="#060a18"/>+ <stop offset="45%" stop-color="#0d1f3c"/>+ <stop offset="100%" stop-color="#1a3050"/>+ </linearGradient>+ <linearGradient id="water-grad" x1="0" y1="0" x2="0" y2="1">+ <stop offset="0%" stop-color="#0e2040"/>+ <stop offset="100%" stop-color="#06111e"/>+ </linearGradient>+ <radialGradient id="moon-glow" cx="50%" cy="50%" r="50%">+ <stop offset="0%" stop-color="#e8dca0" stop-opacity="0.4"/>+ <stop offset="100%" stop-color="transparent"/>+ </radialGradient>+ </defs>+ <!-- Sky -->+ <rect width="800" height="420" fill="url(#sky-grad)"/>+ <!-- Moon glow -->+ <circle cx="600" cy="90" r="80" fill="url(#moon-glow)"/>+ <!-- Moon -->+ <circle cx="600" cy="90" r="28" fill="#e8dca0" opacity=".92"/>+ <!-- Stars -->+ <circle cx="80" cy="40" r="1.2" fill="white" opacity=".9"/>+ <circle cx="220" cy="70" r="1" fill="white" opacity=".7"/>+ <circle cx="340" cy="25" r="1.5" fill="white" opacity=".8"/>+ <circle cx="460" cy="55" r="1" fill="white" opacity=".6"/>+ <circle cx="150" cy="120" r="1" fill="white" opacity=".5"/>+ <circle cx="700" cy="40" r="1.2" fill="white" opacity=".8"/>+ <circle cx="760" cy="130" r="1" fill="white" opacity=".4"/>+ <circle cx="50" cy="180" r="1" fill="white" opacity=".6"/>+ <!-- Distant mountains -->+ <polygon points="0,420 150,260 280,330 420,220 560,300 680,230 800,290 800,420" fill="#0a1a30" opacity=".9"/>+ <!-- Near mountains -->+ <polygon points="0,420 80,330 180,360 300,300 420,340 520,290 640,320 750,280 800,310 800,420" fill="#060e1c"/>+ <!-- Reflection base -->+ <rect y="420" width="800" height="180" fill="url(#water-grad)"/>+ <!-- Water shimmer lines -->+ <line x1="0" y1="440" x2="800" y2="440" stroke="rgba(255,255,255,.04)" stroke-width="1"/>+ <line x1="0" y1="460" x2="800" y2="460" stroke="rgba(255,255,255,.03)" stroke-width="1"/>+ <line x1="0" y1="485" x2="800" y2="485" stroke="rgba(255,255,255,.03)" stroke-width="1"/>+ <!-- Moon reflection -->+ <ellipse cx="600" cy="470" rx="18" ry="8" fill="#e8dca0" opacity=".25"/>+ <ellipse cx="600" cy="500" rx="12" ry="4" fill="#e8dca0" opacity=".12"/>+ </svg>+ </div>+ <div id="caption"><p class="cap-title">Through the Portal</p><p class="cap-sub">Keep scrolling</p></div>+ <div id="frame"><div class="frame-border" style="inset:28%"></div></div></div>- <div id="caption"><h2>Through the Portal</h2><p>Scroll to exit</p></div>- <div id="frame"><div class="frame-border" style="inset:28%"></div></div></div>+ <div class="spacer">The page moves on ↓</div>+ </div>+ <div class="hb-player">+ <button class="hb-play" type="button" id="btn-scroll" data-hb-autoscroll><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M19 12l-7 7-7-7"/></svg>Play</button>+ <button class="hb-play" type="button" id="btn-top" data-hb-top><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19V5M5 12l7-7 7 7"/></svg>Back to top</button></div>- <div class="spacer">Through the portal ↓</div>- </div>- <aside>- <p class="note">clip-path: inset() starts at ~30% on each side (showing 40% width/height) and collapses to 0. Combined with sticky positioning, it reads as the camera flying INTO the image.</p>- <div class="lbl">Zoom progress</div>- <div class="kv"><span>Section</span><span class="v" id="zp">0%</span></div>- <div class="div"></div>- <div><div class="lbl" id="ss-lbl">Start size</div>- <div class="sr"><input type="range" id="ss-sl" aria-labelledby="ss-lbl" min="20" max="60" value="30"><span class="sv" id="ss-val">30%</span></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, then scroll again or press Play.</p></div>+ </div>+ <div class="hb-settings">+ <div class="hb-setting">+ <p class="hb-setting-name" id="start-lbl">Starting window</p>+ <div class="seg" id="start-seg" role="group" aria-labelledby="start-lbl">+ <button type="button" data-start="40" aria-pressed="false">Small</button>+ <button type="button" data-start="30" class="on" aria-pressed="true">Medium</button>+ <button type="button" data-start="20" aria-pressed="false">Large</button>+ </div>+ <p class="hb-hint">How much of the picture shows before you scroll.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="corners-lbl">Corners</p>+ <div class="seg" id="corners-seg" role="group" aria-labelledby="corners-lbl">+ <button type="button" data-radius="0" aria-pressed="false">Square</button>+ <button type="button" data-radius="16" class="on" aria-pressed="true">Rounded</button>+ <button type="button" data-radius="32" aria-pressed="false">Very rounded</button>+ </div>+ <p class="hb-hint">The window's corners straighten as it opens.</p>+ </div></div>- <div><div class="lbl" id="br-lbl">Border radius start</div>- <div class="sr"><input type="range" id="br-sl" aria-labelledby="br-lbl" min="0" max="32" value="16"><span class="sv" id="br-val">16px</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">+ <label class="hb-switch-row"><span>Shows the starting frame</span><input class="hb-switch" type="checkbox" role="switch" id="frame-tog" checked autocomplete="off"></label>+ <p class="hb-hint">A faint outline marks where the window began.</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="div"></div>- <label class="tog" for="portal-tog"><input type="checkbox" id="portal-tog" checked><span>Portal clip-path mode</span></label>- <label class="tog" for="frame-tog"><input type="checkbox" id="frame-tog" checked><span>Show frame</span></label>- <div class="div"></div>- <button class="rst" id="rst">Reset scroll</button>- </aside>-</div>+ <div class="hb-card">+ <p class="hb-prompt">Add a zoom-into-image effect to [your featured picture]. Pin the picture in place while the visitor scrolls through a section a couple of screens tall, and show only a small window of it at first. As they scroll, open that window outward in step with the scroll until the picture fills the whole frame, then fade in a caption. Uncover the picture by clipping it rather than scaling it up, so it stays sharp, and let scrolling back up close the window again. If the visitor has reduced motion turned on, show the full picture and the caption from the start. 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>Hero images</li><li>Gallery intros</li><li>Section breaks</li></ul>+ <h3>Avoid on</h3>+ <ul class="hb-tags hb-avoid"><li>Small images</li><li>Text-heavy pages</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 stage=document.getElementById('stage'),zoomSec=document.getElementById('zoom-section');const zoomImg=document.getElementById('zoom-img'),caption=document.getElementById('caption');- const zp=document.getElementById('zp'),frameEl=document.getElementById('frame');- const ssSl=document.getElementById('ss-sl'),ssVal=document.getElementById('ss-val');- const brSl=document.getElementById('br-sl'),brVal=document.getElementById('br-val');- const portalTog=document.getElementById('portal-tog'),frameTog=document.getElementById('frame-tog');+ const frameEl=document.getElementById('frame'),frameBorder=frameEl.querySelector('.frame-border');+ const frameTog=document.getElementById('frame-tog');+ const motionMQ=window.matchMedia('(prefers-reduced-motion:reduce)');let startPct=30,brStart=16,ticking=false;const clamp=(v,a,b)=>Math.min(Math.max(v,a),b),lerp=(a,b,t)=>a+(b-a)*t;- const motionOk=!window.matchMedia('(prefers-reduced-motion:reduce)').matches;function update(){+ ticking=false;+ // reduced motion: the CSS rule above shows the full picture and the caption, whatever the scroll position+ if(motionMQ.matches)return;const st=stage.scrollTop,stageH=stage.clientHeight;const pinStart=zoomSec.offsetTop,budget=zoomSec.offsetHeight-stageH;const p=clamp((st-pinStart)/budget,0,1);- zp.textContent=Math.round(p*100)+'%';- if(!motionOk){ticking=false;return;}const inset=lerp(startPct,0,p);const radius=lerp(brStart,0,p);- if(portalTog.checked){- zoomImg.style.clipPath=`inset(${inset.toFixed(2)}% round ${radius.toFixed(1)}px)`;- }else{- zoomImg.style.clipPath=`inset(${inset.toFixed(2)}%)`;- }+ zoomImg.style.clipPath=`inset(${inset.toFixed(2)}% round ${radius.toFixed(1)}px)`;caption.style.opacity=p>0.88?((p-0.88)/0.12).toFixed(3):'0';- ticking=false;}stage.addEventListener('scroll',()=>{if(!ticking){requestAnimationFrame(update);ticking=true}},{passive:true});- ssSl.addEventListener('input',()=>{startPct=+ssSl.value;ssVal.textContent=startPct+'%';- frameEl.querySelector('.frame-border').style.inset=startPct+'%';update()});- brSl.addEventListener('input',()=>{brStart=+brSl.value;brVal.textContent=brStart+'px';update()});- portalTog.addEventListener('change',update);+ motionMQ.addEventListener('change',update);++ 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('start-seg',d=>{startPct=+d.start;frameBorder.style.inset=(startPct-2)+'%';update()});+ choices('corners-seg',d=>{brStart=+d.radius;stage.style.setProperty('--br-start',brStart);update()});frameTog.addEventListener('change',()=>{frameEl.style.opacity=frameTog.checked?'1':'0'});- document.getElementById('rst').addEventListener('click',()=>{stage.scrollTop=0;update()});update();</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 0983006f..2882e792 100644--- a/index.html+++ b/index.html@@ -897,7 +897,7 @@ const CATS=[['counter-animation','Counter Animation','Numbers count 0 → target with easing on scroll entry — four formats and configurable curve.'],['progress-bar','Progress Bar','Reading progress in three styles — top bar, circular ring, and side rail — driven by scrollTop / scrollHeight.'],['section-wipe','Section Wipe','The next section slides over the current via sticky z-index stacking — scale-down adds depth.'],- ['zoom-into-image','Zoom Into Image','clip-path expands from a framed card to full-bleed as you scroll — the portal effect.'],+ ['zoom-into-image','Zoom Into Image','A small window opens up to fill the box as you scroll. Best for hero images.'],['scroll-image-sequence','Scroll Image Sequence','A canvas pinned with sticky; scroll progress maps to a frame index — the Apple product-scroll technique, frames drawn procedurally.'],['smooth-scroll','Smooth (Inertia) Scroll','Wheel and touch input eased toward a target each frame — weighted, gliding momentum instead of native jumps.'],['text-fill-on-scroll','Text Fill on Scroll','A pinned paragraph fills word by word as you scroll — pause mid-read, scroll back and it un-reads.'],