Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

feat: 3D Carousel (06.19)

matin383148ca764a
diff --git a/README.md b/README.md
index 60328023..6ddc499d 100644
--- a/README.md
+++ b/README.md
@@ -209,6 +209,7 @@ All 129 techniques, each linked to its live demo.
- **[Volumetric Smoke](animations/06-3d-advanced/volumetric-smoke/)** — Soft smoke curls upward, drawn as a real 3D cloud. Best for moody backgrounds.
- **[Morphing Blob](animations/06-3d-advanced/morphing-blob/)** — Blobs melt together, and one drop chases your pointer. Best for hero sections.
- **[3D Flip Card](animations/06-3d-advanced/flip-card-3d/)** — A card turns over in 3D to show its back. Best for profile and product cards.
+- **[3D Carousel](animations/06-3d-advanced/carousel-3d/)** — Cards stand in a ring that spins in 3D as you drag it. Best for image galleries.
</details>
diff --git a/animations/06-3d-advanced/README.md b/animations/06-3d-advanced/README.md
index b13e1f17..d0313427 100644
--- a/animations/06-3d-advanced/README.md
+++ b/animations/06-3d-advanced/README.md
@@ -24,6 +24,7 @@ WebGL, shaders, particles, 3D transforms, and the performance-sensitive effects
| [Volumetric Smoke](volumetric-smoke/) | Soft smoke curls upward, drawn as a real 3D cloud. Best for moody backgrounds. |
| [Morphing Blob](morphing-blob/) | Blobs melt together, and one drop chases your pointer. Best for hero sections. |
| [3D Flip Card](flip-card-3d/) | A card turns over in 3D to show its back. Best for profile and product cards. |
+| [3D Carousel](carousel-3d/) | Cards stand in a ring that spins in 3D as you drag it. Best for image galleries. |
## Key concepts
diff --git a/animations/06-3d-advanced/carousel-3d/README.md b/animations/06-3d-advanced/carousel-3d/README.md
new file mode 100644
index 00000000..a940a777
--- /dev/null
+++ b/animations/06-3d-advanced/carousel-3d/README.md
@@ -0,0 +1,62 @@
+# 3D Carousel
+
+## What it is
+A 3D carousel stands its cards in a ring and turns the whole ring to bring one card to the front. Each card is turned by an equal share of the circle and pushed out from the middle by the same distance, so the cards beside the front one lean away and the ones behind show their backs. Dragging spins the ring, and when you let go it coasts a little before it settles on the nearest card.
+
+## When to use it
+- Image galleries and portfolios where browsing should feel playful
+- Product pickers with a handful of choices, such as colors, models or plans
+- Album covers, book covers or event posters shown one at a time
+- Landing page showcases with a small set of cards (about 5 to 12)
+
+## How it works
+Four nested elements carry the 3D. The box has the `perspective` (the camera); inside it one wrapper pushes the ring back by its radius and another tilts it for the view from above; the ring itself is what turns. Every one of them keeps its children in 3D with `preserve-3d`, and each card has a front and a back face that hide when they face away:
+
+```css
+.view { perspective: 900px; }
+.push { transform-style: preserve-3d; transform: translateZ(calc(var(--r) * -1)); }
+.tilt { transform-style: preserve-3d; transform: translateY(calc(var(--r) * -0.11)) rotateX(-14deg); }
+.ring { transform-style: preserve-3d; } /* the script sets rotateY() */
+.face { backface-visibility: hidden; } /* .back is turned 180° */
+```
+
+Card `i` is turned by `i × 360° / N` and pushed out by the radius. N cards with a small gap form a regular polygon, and the distance from its middle to the middle of a side is half a side divided by tan(180° / N). Pushing the ring back by that same radius keeps the front card at its normal size:
+
+```js
+const step = 360 / N;
+const R = cardWidth * 1.12 / (2 * Math.tan(Math.PI / N)); // a gap of 12% of a card
+card.style.transform = `rotateY(${i * step}deg) translateZ(var(--r))`;
+ring.style.transform = `rotateY(${angle}deg)`; // angle -i * step brings card i to the front
+```
+
+Dragging turns pixels into degrees at the ring's radius, so the front card follows the pointer: `angle = startAngle + dx × 180 / (π × R)`. Pointer Events serve mouse, touch and pen alike, and `touch-action: pan-y` lets a vertical swipe still scroll the page. On release, the speed of the last tenth of a second says how far the ring would coast; that place is rounded to the nearest card and the ring eases there, by elapsed time, so it runs at the same speed at any frame rate:
+
+```js
+const GLIDE = FRAME / -Math.log(1 - 0.09); // the easing's time constant, about 177 ms
+const throwDeg = speedPxPerMs * GLIDE * 180 / (Math.PI * R);
+target = Math.round((angle + throwDeg) / step) * step;
+// every frame
+angle += (target - angle) * (1 - Math.pow(1 - 0.09, dt / FRAME));
+```
+
+Because the throw is the pointer's speed times the easing's time constant, the easing starts at the speed the pointer had, and the coast flows on from the drag without a jump. A press that hardly moves brings the pressed card to the front. The arrows and the arrow keys move the target one card at a time, and quick presses add up. Show me turns the ring once all the way round in three seconds, quickly at first and then coasting to a stop on the card it started from.
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Number of cards | 8 | How many cards stand in the ring: 6, 8 or 12. More cards make a wider ring, so each card is drawn smaller to fit the box |
+| Seen from above | on | Tilts the ring back 14 degrees, so the cards behind show above the front ones; off shows the ring straight on |
+| Spins by itself | off | The ring turns 12 degrees a second, waits while you drag and starts again a moment after it settles; under reduced motion it steps one card every three seconds instead |
+
+## Production notes
+- **Accessibility**: give the ring a name and a role (`role="group"` with `aria-roledescription="carousel"`), real buttons for previous and next, and the arrow keys on the focused ring. Announce the card that settles in front through a polite live region, but not while the ring turns by itself.
+- **Moving by itself**: anything that moves on its own for more than five seconds needs a way to stop it (WCAG 2.2.2). Pause the spin while the pointer is over the ring or it has keyboard focus, and offer a pause button.
+- **Reduced motion**: under `prefers-reduced-motion: reduce`, jump from card to card instead of turning. The demo steps one card per drag, arrow or key press, and Show me steps to the next card and back.
+- **Performance**: only the ring's `transform` changes while it moves, so the browser composites the cards without painting them again. `filter`, `overflow: hidden` or an `opacity` below 1 on an element with `preserve-3d` flattens it, and the ring collapses into a flat picture.
+- **Libraries**: Swiper's coverflow and creative effects, GSAP Draggable with its InertiaPlugin for the throw, and Framer Motion's `drag` with momentum all build the same thing. Three.js gives a real 3D scene with lights and reflections when CSS 3D is not enough.
+
+## See also
+- [3D Flip Card](../flip-card-3d/) — one card turns over in 3D to show its back
+- [Parallax 3D Tilt](../parallax-3d-tilt/) — a card leans toward the pointer
+- [Snap Scrolling](../../01-scroll-based/snap-scrolling/) — a flat gallery that settles on one card at a time
+- [Swipe to Dismiss](../../04-micro-interactions/swipe-to-dismiss/) — a card that follows a drag and flies off on a flick
diff --git a/animations/06-3d-advanced/carousel-3d/index.html b/animations/06-3d-advanced/carousel-3d/index.html
new file mode 100644
index 00000000..abaac06d
--- /dev/null
+++ b/animations/06-3d-advanced/carousel-3d/index.html
@@ -0,0 +1,311 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>3D Carousel — Animation Handbook</title>
+ <meta name="description" content="Cards stand in a ring that spins in 3D as you drag it. Best for image galleries.">
+ <link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/carousel-3d/">
+ <link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png">
+ <link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
+ <link rel="apple-touch-icon" href="../../../apple-touch-icon.png">
+ <meta property="og:type" content="article">
+ <meta property="og:site_name" content="Animation Handbook">
+ <meta property="og:title" content="3D Carousel — Animation Handbook">
+ <meta property="og:description" content="Cards stand in a ring that spins in 3D as you drag it. Best for image galleries.">
+ <meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/carousel-3d/">
+ <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="3D Carousel — Animation Handbook">
+ <meta name="twitter:description" content="Cards stand in a ring that spins in 3D as you drag it. Best for image galleries.">
+ <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": "3D Carousel", "name": "3D Carousel", "description": "Cards stand in a ring that spins in 3D as you drag it. Best for image galleries.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/carousel-3d/", "inLanguage": "en", "articleSection": "3D & Advanced", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, 3D & Advanced, 3D Carousel"}</script>
+ <style>
+ :root{--ui-accent:#3fd6c4}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ .stage{display:flex;flex-direction:column;background:radial-gradient(120% 90% at 50% 8%,#17131f,#08070a)}
+ /* The ring's box: the camera (perspective) looks at it, and dragging anywhere on it turns the ring. A vertical swipe
+ still scrolls the page. --r (radius) and --cw (card width) are set by the script; --tilt and --lift by Seen from above. */
+ .view{position:relative;flex:1;min-height:0;display:grid;place-items:center;perspective:900px;touch-action:pan-y;cursor:grab;
+ -webkit-user-select:none;user-select:none;--tilt:-14deg;--lift:-.11}
+ .view.grabbing{cursor:grabbing}
+ /* push: the ring's middle sits one radius behind the screen, so the front card keeps its size. tilt: the view from above,
+ lifted so the tilted ring stays in the middle; it eases only once the first size is set (ready). ring: the script turns it. */
+ .push,.tilt,.ring,.card{transform-style:preserve-3d}
+ .push{transform:translateZ(calc(var(--r,200px) * -1))}
+ .tilt{transform:translateY(calc(var(--r,200px) * var(--lift))) rotateX(var(--tilt))}
+ .view.ready .tilt{transition:transform .6s cubic-bezier(.22,1,.36,1)}
+ .ring{position:relative;width:var(--cw,160px);aspect-ratio:3/4;will-change:transform}
+ .card{position:absolute;inset:0}
+ .face{position:absolute;inset:0;border-radius:10px;overflow:hidden;backface-visibility:hidden;-webkit-backface-visibility:hidden}
+ /* Each front is a small landscape in its own hue (--h): a sun, two hills and the sky, with its name on a dark strip */
+ .front{display:flex;align-items:flex-end;border:1px solid rgba(255,255,255,.16);
+ background:radial-gradient(circle at 70% 28%,hsl(var(--h) 90% 88%) 0 9%,transparent 10%),
+ radial-gradient(130% 62% at 22% 108%,hsl(var(--h) 42% 19%) 0 60%,transparent 61%),
+ radial-gradient(110% 55% at 88% 104%,hsl(var(--h) 38% 31%) 0 60%,transparent 61%),
+ linear-gradient(hsl(var(--h) 62% 62%),hsl(calc(var(--h) + 30) 55% 40%))}
+ .front span{flex:1;min-width:0;padding:7% 9%;background:rgba(8,8,12,.76);color:#f4f4f2;font-weight:700;font-size:max(11px,calc(var(--cw) * .085));
+ line-height:1.25;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
+ .back{transform:rotateY(180deg);border:1px solid hsl(var(--h) 28% 30%);background:linear-gradient(hsl(var(--h) 30% 18%),hsl(var(--h) 34% 9%))}
+ /* Previous, the card number and Next, under the ring */
+ .nav{flex:none;display:flex;align-items:center;justify-content:center;gap:12px;padding:0 0 clamp(10px,2vw,16px)}
+ .arrow{display:grid;place-items:center;width:44px;height:44px;border-radius:50%;border:1px solid rgba(255,255,255,.24);background:rgba(255,255,255,.06);color:#f4f4f2;cursor:pointer}
+ .arrow svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
+ .count{min-width:64px;text-align:center;font-size:14px;font-weight:600;color:#d6d6da;font-variant-numeric:tabular-nums}
+ .sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
+ @media(hover:hover){.arrow:hover{background:rgba(255,255,255,.14);border-color:rgba(255,255,255,.4)}}
+ @media(prefers-reduced-motion:reduce){.view.ready .tilt{transition:none}}
+ </style>
+ <link rel="stylesheet" href="../../../assets/css/demo-page.css?v=6">
+ <script src="../../../assets/js/demo-page.js?v=6" defer></script>
+</head>
+<body class="hb" data-hb-kind="do" 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="../flip-card-3d/" rel="prev" aria-label="Previous: 3D Flip Card"><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>3D Flip Card</span></a></span>
+</nav>
+<main class="hb-page">
+ <header class="hb-head">
+ <p class="hb-cat">06.19 · 3D &amp; Advanced</p>
+ <h1>3D Carousel</h1>
+ <p class="hb-lede">Cards stand in a ring that spins in 3D as you drag it. Best for image galleries.</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">Drag it</h2><p>Drag the cards sideways and let go, use the arrows, or press Show me.</p></div>
+ </div>
+ <div class="stage" id="stage">
+ <div class="view" id="view" tabindex="0" role="group" aria-roledescription="carousel" aria-label="Picture cards. Drag sideways or press the arrow keys to turn the ring.">
+ <div class="push"><div class="tilt"><div class="ring" id="ring"></div></div></div>
+ </div>
+ <div class="nav">
+ <button class="arrow" type="button" id="prev" aria-label="Previous card"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg></button>
+ <span class="count" id="count" aria-hidden="true">1 of 8</span>
+ <button class="arrow" type="button" id="next" aria-label="Next card"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></button>
+ <span class="sr" id="status" role="status"></span>
+ </div>
+ </div>
+ <div class="hb-player">
+ <button class="hb-play" type="button" id="btn-demo" data-hb-demo><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>Show me</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>
+ </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 try it again or press Show me.</p></div>
+ </div>
+ <div class="hb-settings">
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="count-lbl">Number of cards</p>
+ <div class="seg" id="count-seg" role="group" aria-labelledby="count-lbl">
+ <button type="button" data-n="6" aria-pressed="false">6</button>
+ <button type="button" data-n="8" class="on" aria-pressed="true">8</button>
+ <button type="button" data-n="12" aria-pressed="false">12</button>
+ </div>
+ <p class="hb-hint">More cards make a wider ring of smaller cards.</p>
+ </div>
+ <div class="hb-setting">
+ <label class="hb-switch-row"><span>Seen from above</span><input class="hb-switch" type="checkbox" role="switch" id="tilt-tog" checked autocomplete="off"></label>
+ <p class="hb-hint">The ring leans back, so you look down on it a little.</p>
+ </div>
+ <div class="hb-setting">
+ <label class="hb-switch-row"><span>Spins by itself</span><input class="hb-switch" type="checkbox" role="switch" id="spin-tog" autocomplete="off"></label>
+ <p class="hb-hint">It turns slowly on its own and waits while you drag.</p>
+ </div>
+ </div>
+ </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 3D carousel to [the cards or pictures you want to show]. Stand the cards in a ring: turn each one by an equal share of a full circle, push it out from the middle by the same distance, and give the container a 3D perspective. Dragging sideways turns the whole ring with the pointer or finger; on release it keeps a little speed, then settles with the nearest card facing front. Previous and next buttons and the arrow keys turn it one card at a time. Change only the ring's rotation so it stays smooth. When the settings include it, the ring turns slowly by itself. If the visitor has reduced motion turned on, jump from card to card without turning. 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>Image galleries</li><li>Product picks</li><li>Portfolios</li><li>Album covers</li></ul>
+ <h3>Avoid on</h3>
+ <ul class="hb-tags hb-avoid"><li>Long lists</li><li>Text-heavy cards</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 view=document.getElementById('view'),ring=document.getElementById('ring');
+ const countEl=document.getElementById('count'),statusEl=document.getElementById('status');
+ const reduce=matchMedia('(prefers-reduced-motion:reduce)');
+ // Twelve pictures around the color wheel, 30° of hue apart; a ring of N cards takes N of them, spread evenly
+ const NAMES=['Canyon','Dunes','Savanna','Meadow','Forest','Jungle','Lagoon','Glacier','Fjord','Dusk','Orchids','Coral'];
+ const FRAME=1000/60,K=.09,GLIDE=FRAME/-Math.log(1-K); // the settle closes 9% of the gap every 60th of a second; GLIDE is its time constant (ms)
+ const P=900,RUN_MS=3000,SPIN=12; // the camera's distance (px), a Show me run (ms), Spins by itself (degrees a second)
+ let N=8,step=45,R=200,angle=0,target=null,drag=null,run=null,spinOn=false,spinV=0,idle=0,raf=0,lastT=null,front=-1,holdTimer=0,names=[];
+
+ // The cards: card i is turned by i steps and pushed out by the radius, so the ring's angle -i*step brings it to the front.
+ function build(){
+ step=360/N;names=[];ring.textContent='';
+ for(let i=0;i<N;i++){
+ const k=Math.round(i*12/N)%12,card=document.createElement('div');
+ card.className='card';card.dataset.i=i;card.style.setProperty('--h',k*30);
+ card.style.transform=`rotateY(${i*step}deg) translateZ(var(--r))`;
+ card.innerHTML=`<div class="face front"><span>${NAMES[k]}</span></div><div class="face back"></div>`;
+ ring.appendChild(card);names.push(NAMES[k]);
+ }
+ angle=0;target=null;front=-1;layout();render();
+ }
+ // The card width that fits: a 3:4 card two thirds of the box's height, made smaller until the ring's outer corners, seen at
+ // their depth, fit 94% of its width. The radius puts N cards with a gap of 12% of a card around a polygon.
+ function layout(){
+ const W=view.clientWidth,H=view.clientHeight,t=Math.tan(Math.PI/N);
+ let cw=Math.min(H*.5,220);
+ for(;cw>44;cw-=2){const r=cw*1.12/(2*t);if(2*Math.hypot(r,cw/2)*P/(P+.8*r)<=W*.94)break;}
+ R=cw*1.12/(2*t);
+ view.style.setProperty('--cw',cw.toFixed(1)+'px');view.style.setProperty('--r',R.toFixed(1)+'px');
+ }
+ const wrap=a=>((a%360)+360)%360;
+ const snap=a=>Math.round(a/step)*step;
+ const nearest=a=>a+360*Math.round((angle-a)/360); // the same place as a, the shortest way round from where the ring is
+ function render(){
+ ring.style.transform=`rotateY(${angle.toFixed(2)}deg)`;
+ const i=((Math.round(-angle/step)%N)+N)%N;
+ if(i!==front){front=i;countEl.textContent=`${i+1} of ${N}`;}
+ }
+ // The card in front is announced when the ring comes to rest after the visitor (or Show me) moved it, never while it spins by itself
+ function rested(){statusEl.textContent=`Card ${front+1} of ${N}: ${names[front]}`;}
+ function jump(a){run=null;target=null;angle=wrap(a);render();rested();}
+
+ // One frame loop, running only while something moves. Show me runs by its own clock; a settle closes a share of the gap per
+ // 60th of a second; Spins by itself eases up to its speed once the ring has been left alone for 1.2 s.
+ function wake(){if(!raf){lastT=null;raf=requestAnimationFrame(tick);}}
+ function tick(ts){
+ raf=0;
+ const dt=lastT===null?0:Math.min(ts-lastT,50);lastT=ts;
+ let more=!!drag;
+ if(run){
+ if(run.t0===null)run.t0=ts;
+ const p=Math.min(1,(ts-run.t0)/RUN_MS),e=1-Math.pow(1-p,4)*(1+4*p); // speeds up for a quarter, then coasts to a stop
+ angle=run.a0+(run.a1-run.a0)*e;
+ if(p<1)more=true;else{angle=wrap(run.a1);run=null;idle=0;rested();}
+ }else if(target!==null&&!drag){
+ angle+=(target-angle)*(1-Math.pow(1-K,dt/FRAME));
+ if(Math.abs(target-angle)<.01){angle=wrap(target);target=null;idle=0;rested();}else more=true;
+ }
+ if(spinOn&&!run&&!drag&&target===null){
+ idle+=dt;more=true;
+ if(reduce.matches){if(idle>=3000){idle=0;angle=wrap(snap(angle)-step);}} // no spin: one card every three seconds
+ else{spinV+=((idle>1200?SPIN:0)-spinV)*(1-Math.pow(1-.04,dt/FRAME));angle=wrap(angle-spinV*dt/1000);}
+ }
+ render();
+ if(more)raf=requestAnimationFrame(tick);
+ }
+ document.addEventListener('visibilitychange',()=>{lastT=null;});
+
+ // Dragging: the front card follows the pointer (pixels become degrees at the ring's radius). On release, the speed of the
+ // last tenth of a second says how far the ring would coast in GLIDE ms; that place is rounded to a card and the ring eases
+ // there, starting at the pointer's speed. A press that hardly moves brings the pressed card to the front. Under reduced
+ // motion the ring does not follow: a drag past 30px steps one card.
+ view.addEventListener('pointerdown',e=>{
+ if(e.button>0)return;
+ run=null;target=null;spinV=0;idle=0;
+ drag={id:e.pointerId,x:e.clientX,a:angle,moved:false,card:e.target.closest('.card'),pts:[[e.timeStamp,e.clientX]]};
+ view.setPointerCapture(e.pointerId);view.classList.add('grabbing');wake();
+ });
+ view.addEventListener('pointermove',e=>{
+ if(!drag||e.pointerId!==drag.id)return;
+ const dx=e.clientX-drag.x;
+ if(Math.abs(dx)>5)drag.moved=true;
+ drag.pts.push([e.timeStamp,e.clientX]);if(drag.pts.length>8)drag.pts.shift();
+ if(!reduce.matches)angle=drag.a+dx*180/(Math.PI*R);
+ });
+ function release(e,cancelled){
+ if(!drag||e.pointerId!==drag.id)return;
+ const d=drag,dx=e.clientX-d.x;drag=null;view.classList.remove('grabbing');idle=0;
+ if(!d.moved&&d.card&&!cancelled){const a=-d.card.dataset.i*step;if(reduce.matches)jump(a);else{target=nearest(a);wake();}return;}
+ if(reduce.matches){if(!cancelled&&Math.abs(dx)>30)jump(snap(angle)+(dx>0?step:-step));return;}
+ // The speed over the last 100 ms of moves; a pointer that rested for 80 ms before letting go has none
+ const last=d.pts[d.pts.length-1],first=d.pts.find(p=>last[0]-p[0]<100);
+ const v=!cancelled&&e.timeStamp-last[0]<80&&last[0]>first[0]?(last[1]-first[1])/(last[0]-first[0]):0;
+ target=snap(angle+Math.max(-360,Math.min(360,v*GLIDE*180/(Math.PI*R))));wake();
+ }
+ view.addEventListener('pointerup',e=>release(e,false));
+ view.addEventListener('pointercancel',e=>release(e,true));
+
+ // The arrows and the arrow keys move the target one card; quick presses add up. Next brings the card on the right to the front.
+ function go(dir){
+ run=null;spinV=0;idle=0;
+ if(reduce.matches){jump(snap(angle)-dir*step);return;}
+ target=(target===null?snap(angle):target)-dir*step;wake();
+ }
+ document.getElementById('prev').addEventListener('click',()=>go(-1));
+ document.getElementById('next').addEventListener('click',()=>go(1));
+ view.addEventListener('keydown',e=>{
+ if(e.key==='ArrowRight'||e.key==='ArrowLeft'){e.preventDefault();go(e.key==='ArrowRight'?1:-1);}
+ });
+
+ // Show me: one flick that turns the ring all the way round in three seconds and stops on the card it started from. Under
+ // reduced motion it steps to the next card without turning, holds it for 1.2 s and steps back.
+ function stopHold(){clearTimeout(holdTimer);holdTimer=0;}
+ document.getElementById('btn-demo').addEventListener('click',()=>{
+ stopHold();drag=null;target=null;spinV=0;idle=0;
+ if(reduce.matches){const a=snap(angle);jump(a-step);holdTimer=setTimeout(()=>{holdTimer=0;jump(a);},1200);return;}
+ run={a0:angle,a1:snap(angle)-360,t0:null};wake();
+ });
+ document.getElementById('btn-reset').addEventListener('click',()=>{
+ stopHold();run=null;drag=null;spinV=0;idle=0;
+ if(reduce.matches)jump(0);else{target=nearest(0);wake();}
+ });
+ // The visitor pressed, typed, scrolled or touched inside the stage: a run under way stops and the ring settles on the nearest
+ // card, unless the same press starts a drag (that comes next and takes the ring from where it is).
+ document.addEventListener('hb:input',()=>{
+ if(holdTimer)stopHold();
+ if(run){run=null;target=snap(angle);wake();}
+ });
+
+ 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('count-seg',d=>{stopHold();run=null;N=+d.n;build();rested();if(spinOn)wake();});
+ document.getElementById('tilt-tog').addEventListener('change',e=>{
+ view.style.setProperty('--tilt',e.target.checked?'-14deg':'0deg');view.style.setProperty('--lift',e.target.checked?'-.11':'0');
+ });
+ // Switched on, it starts at once; switched off, the ring settles on the next card in the way it was turning
+ document.getElementById('spin-tog').addEventListener('change',e=>{
+ spinOn=e.target.checked;
+ if(spinOn){idle=1200;spinV=0;}else if(!run&&!drag&&target===null&&spinV){target=Math.floor(angle/step)*step;spinV=0;}
+ wake();
+ });
+ addEventListener('resize',layout);
+ build();
+ void view.offsetWidth;view.classList.add('ready'); // the first size is in place before the tilt starts easing
+</script>
+</body>
+</html>
diff --git a/animations/06-3d-advanced/flip-card-3d/index.html b/animations/06-3d-advanced/flip-card-3d/index.html
index c14c5bc1..2bd6f26b 100644
--- a/animations/06-3d-advanced/flip-card-3d/index.html
+++ b/animations/06-3d-advanced/flip-card-3d/index.html
@@ -81,7 +81,7 @@
<body class="hb" data-hb-kind="do" 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="../morphing-blob/" rel="prev" aria-label="Previous: Morphing Blob"><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>Morphing Blob</span></a></span>
+ <span class="hb-pager"><a href="../morphing-blob/" rel="prev" aria-label="Previous: Morphing Blob"><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>Morphing Blob</span></a><a href="../carousel-3d/" rel="next" aria-label="Next: 3D Carousel"><span><span class="hb-dir">Next: </span>3D Carousel</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">
diff --git a/index.html b/index.html
index e2d7eb15..5abe7672 100644
--- a/index.html
+++ b/index.html
@@ -779,6 +779,19 @@ button,input{font:inherit;color:inherit}
.pv-smoke .s2{left:44%;animation:d-smoke 7s ease-in infinite -2s}
.pv-smoke .s3{left:30%;animation:d-smoke 8s ease-in infinite -4s}
@keyframes d-smoke{0%{transform:translateY(0) scale(.6);opacity:0}30%{opacity:.5}100%{transform:translateY(-170%) scale(1.4);opacity:0}}
+/* six cards in a ring (1cqw is 1% of the stage's width), seen a little from above, that turn one card at a time. The previews'
+ will-change hint names opacity, which flattens 3D in Chrome, so here it names the transform only. */
+.pv-carousel3d{background:radial-gradient(120% 90% at 50% 10%,#17131f,#08070a);container-type:size}
+.pv-carousel3d *{will-change:transform}
+.pv-carousel3d .sc{position:absolute;inset:0;display:grid;place-items:center;perspective:100cqw}
+.pv-carousel3d .tl,.pv-carousel3d .rg,.pv-carousel3d .rg i{transform-style:preserve-3d}
+.pv-carousel3d .tl{transform:translateZ(-21.3cqw) translateY(1cqw) rotateX(-14deg)}
+.pv-carousel3d .rg{position:relative;width:22cqw;aspect-ratio:3/4;animation:d-car3d 9s cubic-bezier(.45,0,.2,1) infinite}
+.pv-carousel3d .rg i{position:absolute;inset:0;transform:rotateY(calc(var(--k) * 60deg)) translateZ(21.3cqw)}
+.pv-carousel3d .rg i::before,.pv-carousel3d .rg i::after{content:"";position:absolute;inset:0;border-radius:5px;backface-visibility:hidden;-webkit-backface-visibility:hidden}
+.pv-carousel3d .rg i::before{border:1px solid rgba(255,255,255,.18);background:radial-gradient(circle at 70% 28%,hsl(calc(var(--k) * 60) 90% 88%) 0 10%,transparent 11%),radial-gradient(130% 55% at 25% 108%,hsl(calc(var(--k) * 60) 42% 20%) 0 60%,transparent 61%),linear-gradient(hsl(calc(var(--k) * 60) 62% 62%),hsl(calc(var(--k) * 60 + 30) 55% 40%))}
+.pv-carousel3d .rg i::after{transform:rotateY(180deg);border:1px solid hsl(calc(var(--k) * 60) 28% 30%);background:hsl(calc(var(--k) * 60) 30% 15%)}
+@keyframes d-car3d{0%,11.7%{transform:rotateY(0)}16.7%,28.3%{transform:rotateY(-60deg)}33.3%,45%{transform:rotateY(-120deg)}50%,61.7%{transform:rotateY(-180deg)}66.7%,78.3%{transform:rotateY(-240deg)}83.3%,95%{transform:rotateY(-300deg)}100%{transform:rotateY(-360deg)}}
/* ── bespoke: 07 Ambient & Background ── */
.pv-grain2{background:radial-gradient(circle at 50% 40%,#1a1710,#08080a);overflow:hidden}
@@ -1007,7 +1020,7 @@ button,input{font:inherit;color:inherit}
<section class="wrap home-hero" aria-labelledby="hero-title">
<span class="float fl1" aria-hidden="true"></span><span class="float fl2" aria-hidden="true"></span><span class="float fl3" aria-hidden="true"></span>
<span class="float fl4" aria-hidden="true"></span><span class="float fl5" aria-hidden="true"></span><span class="float fl6" aria-hidden="true"></span>
- <p class="pill"><span class="pill-dot" aria-hidden="true"></span>129 free animations · no coding needed</p>
+ <p class="pill"><span class="pill-dot" aria-hidden="true"></span>130 free animations · no coding needed</p>
<h1 class="h1" id="hero-title">What do you want to animate?</h1>
<p class="sub">Pick a place, or describe it in your own words. Every animation plays live, and each one comes with a ready-made prompt for your AI assistant.</p>
<form class="search" id="search-form" role="search" action="./" method="get">
@@ -1064,8 +1077,8 @@ button,input{font:inherit;color:inherit}
<p class="empty-s">Try a simpler word, or pick one of these:</p>
<p class="pop"><button type="button" data-q="fade in">fade in</button><button type="button" data-q="typing text">typing text</button><button type="button" data-q="loading spinner">loading spinner</button><button type="button" data-q="parallax">parallax</button><button type="button" data-q="confetti">confetti</button></p>
</div>
- <div class="more" id="more"><button type="button" class="bigbtn" id="more-btn"><span id="more-label">Browse all 129 animations</span><svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M6 13l6 6 6-6"/></svg></button></div>
- <noscript><p class="noscript">This page shows its animations with JavaScript. All 129 are still easy to reach: see the <a href="https://github.com/matinmonshizadeh/animation-handbook#categories">category list on GitHub</a> or the <a href="sitemap.xml">full sitemap</a>. Each demo is a page of its own under <code>/animations/&lt;category&gt;/&lt;name&gt;/</code>.</p></noscript>
+ <div class="more" id="more"><button type="button" class="bigbtn" id="more-btn"><span id="more-label">Browse all 130 animations</span><svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M6 13l6 6 6-6"/></svg></button></div>
+ <noscript><p class="noscript">This page shows its animations with JavaScript. All 130 are still easy to reach: see the <a href="https://github.com/matinmonshizadeh/animation-handbook#categories">category list on GitHub</a> or the <a href="sitemap.xml">full sitemap</a>. Each demo is a page of its own under <code>/animations/&lt;category&gt;/&lt;name&gt;/</code>.</p></noscript>
</section>
<section class="how" id="how" aria-labelledby="how-title">
@@ -1083,7 +1096,7 @@ button,input{font:inherit;color:inherit}
<footer class="wrap foot">
<a class="brand" href="./"><svg class="mark" viewBox="0 0 32 32" aria-hidden="true"><circle class="ring" cx="11.16" cy="20.84" r="6.1"/><circle class="ring" cx="15.12" cy="16.88" r="6.1"/><circle class="ring" cx="18.51" cy="13.49" r="6.1"/><circle class="ball" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>
- <p class="foot-t">129 web animations with live demos and copyable prompts.</p>
+ <p class="foot-t">130 web animations with live demos and copyable prompts.</p>
<nav class="nav" aria-label="Footer"><a class="lnk" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener noreferrer">GitHub</a><a class="lnk" href="#top">Back to top</a></nav>
</footer>
<div class="toast" id="toast" role="status" aria-live="polite"><span class="ok" aria-hidden="true"><svg class="i" viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="toast-t"></span></div>
@@ -1251,6 +1264,7 @@ const CATS=[
['volumetric-smoke','Volumetric Smoke','Soft smoke curls upward, drawn as a real 3D cloud. Best for moody backgrounds.'],
['morphing-blob','Morphing Blob','Blobs melt together, and one drop chases your pointer. Best for hero sections.'],
['flip-card-3d','3D Flip Card','A card turns over in 3D to show its back. Best for profile and product cards.'],
+ ['carousel-3d','3D Carousel','Cards stand in a ring that spins in 3D as you drag it. Best for image galleries.'],
]
},
{
@@ -1284,7 +1298,7 @@ const PV={
'svg-line-draw':'linedraw','scrollspy-nav':'spy','scroll-background-color':'bgblend',
'hamburger-menu-toggle':'hamb','theme-toggle-morph':'thememorph','copy-to-clipboard':'copyfx',
'star-rating':'stars','toast-notification':'toast','segmented-control':'segct','pull-to-refresh':'pullref',
- 'flip-card-3d':'flip3d','matrix-rain':'matrix','plasma':'plasmapv',
+ 'flip-card-3d':'flip3d','carousel-3d':'carousel3d','matrix-rain':'matrix','plasma':'plasmapv',
'parallax-depth-of-field':'dof','parallax-scrolling':'plx','reverse-scrolling-columns':'revcol',
'cover-card-to-fixed-header':'cover','fly-in-fly-out-contact-list':'flylist','stacking-cards':'stack',
'scroll-trigger':'trigger','scrub-animation':'scrub','pin-animation':'pin','snap-scrolling':'snap',
@@ -1439,6 +1453,7 @@ const PLACES={
'volumetric-smoke':['bg'],
'morphing-blob':['bg'],
'flip-card-3d':['imgcard'],
+ 'carousel-3d':['imgcard'],
// 07
'animated-gradient-background':['bg'],
'mesh-gradient':['bg'],
@@ -1469,6 +1484,7 @@ function pvMarkup(k){
case 'sig4': return '<span class="s4r anim"></span><span class="s4r r2 anim"></span><span class="s4r r3 anim"></span><span class="s4d"></span>';
case 'sig5': return '<span class="s5 anim"></span><span class="s5 anim"></span><span class="s5 anim"></span>';
case 'sig6': return '<div class="cube anim"><span class="face f1"></span><span class="face f2"></span><span class="face f3"></span><span class="face f4"></span><span class="face f5"></span><span class="face f6"></span></div>';
+ case 'carousel3d': return '<div class="sc"><div class="tl"><div class="rg anim">'+[0,1,2,3,4,5].map(k=>'<i style="--k:'+k+'"></i>').join('')+'</div></div></div>';
case 'sig7': return '<span class="s7 anim"></span>';
case 'aurora': return '<span class="band b1 anim"></span><span class="band b2 anim"></span><span class="band b3 anim"></span>';
case 'mesh': return '<span class="m m1 anim"></span><span class="m m2 anim"></span><span class="m m3 anim"></span>';
diff --git a/sitemap.xml b/sitemap.xml
index 23cc35d9..3fff7d41 100644
--- a/sitemap.xml
+++ b/sitemap.xml
@@ -113,6 +113,7 @@
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/volumetric-smoke/</loc><lastmod>2026-07-14</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/morphing-blob/</loc><lastmod>2026-07-14</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/flip-card-3d/</loc><lastmod>2026-07-14</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+ <url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/carousel-3d/</loc><lastmod>2026-10-01</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/animated-gradient-background/</loc><lastmod>2026-07-14</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/mesh-gradient/</loc><lastmod>2026-07-14</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/aurora/</loc><lastmod>2026-07-14</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>