Scroll Polaroid Stack Flip — Photo Wall Sort, GSAP
Scroll Polaroid Stack Flip · Scroll · Plain HTML, CSS & JS · Live preview
About this UI Snippet
Scroll Polaroid Stack Flip — A Pile of Photos That Sorts Itself Onto a Corkboard

A messy pile of instant photos sits on a corkboard. As you scroll, the top one lifts off, flips over in mid-air to show a handwritten note and a date stamp on the back, turns face up again and lands in its spot on the board at a slight tilt. A strip of tape sticks it down, and the photo develops from a pale, washed-out print to full colour, the way a real instant photo does. A counter shows how many photos are on the wall, and a handwritten "Summer, kept." appears when the last one lands. Scroll back up and everything comes off the wall in reverse.
One timeline, one unit per photo
The stage is pinned with ScrollTrigger and drives one GSAP timeline with scrub: 0.8. Each photo owns one unit of that timeline: from 0 to 0.25 it lifts off the pile (up 46 px, scaled to 1.14, tilted back with rotateX, a deeper shadow and a z-index above the rest), from 0.25 to 0.85 it flies to its slot, and around 0.85 the tape snaps on. The scroll length is worked out from the number of photos, so adding a seventh photo adds its own stretch of scroll automatically.
A real flip with two faces
Each card has a front face (white border, photo, handwritten caption) and a back face (lined paper, note, date stamp) stacked on top of each other with backface-visibility: hidden, and the back is turned with rotateY(180deg). The card itself keeps transform-style: preserve-3d inside a stage with perspective: 1400px. During the flight the card turns a full 360° on the Y axis, so you see the back for the middle half of the trip and it lands face up again. With prefers-reduced-motion, the turn is skipped and the scrub becomes direct.
Developing as it lands
Every photo starts with a filter of high brightness, low saturation, a little sepia, low contrast and a slight blur. A fromTo tween brings it to a neutral filter while the card is in the air, so the picture comes into focus and colour just as it reaches the board. GSAP can tween the whole filter string because both ends list the same functions in the same order. The shadow works the same way: boxShadow tweens from a short resting shadow to a long lifted one and back.
The board layout is just CSS
The final spots are empty .pf-slot elements in a CSS grid (3 × 2 on desktop, 2 × 3 on phones), each with a data-r tilt. The script measures the offset from the pile to the centre of each slot with getBoundingClientRect(), and the tween values are functions, so with invalidateOnRefresh: true ScrollTrigger re-measures them on every resize. Change the grid, the gaps or the breakpoint and the photos still land in the right place. The pile is described the same way: data-x, data-y and data-r on each card set where it lies before it is picked up.
Sized from one variable
Card size, caption size, note size and board cells all come from one --cw custom property that depends on both the screen width and height, so the whole wall fits on a laptop, a tall phone or a wide monitor without scrolling inside the stage. The corkboard is three gradient layers (two speckle patterns over a warm base) with an inset shadow for depth, and the captions and notes use the Caveat handwriting font.
For other stack and card effects, see Scroll Card Deck Shuffle and Scroll Book Shelf Slide.
What's included
Features
Step by step
How to Use
- 1Load GSAP and ScrollTriggerAdd gsap.min.js and ScrollTrigger.min.js from the CDN panel, in that order, before the snippet JS.
- 2Scroll through the stageIt pins in place. Each photo lifts, flips over to show its note, lands on the board, gets taped down and develops. The counter goes up as each one lands.
- 3Scroll back upThe photos come off the board, flip back and drop onto the pile in reverse order.
- 4Use your own photos and notesChange the img src and alt, the caption, the note and the date in each .pf-card.
- 5Add a photoAdd a .pf-card with its pile position (data-x, data-y, data-r) and a matching .pf-slot with its tilt (data-r). Adjust the grid columns or rows if needed, and update the "/ 6" in the counter.
- 6Change the lookEdit --cw for card size, the .pf-stage background for a different board, or the UNDEVELOPED filter in the JS for a stronger or softer developing effect.
Real-world uses
Common Use Cases
Got questions?
Frequently Asked Questions
The final spots are empty .pf-slot elements in a CSS grid. The script measures the offset from the pile to the centre of each slot with getBoundingClientRect(). The tween values are functions and the ScrollTrigger has invalidateOnRefresh: true, so the offsets are measured again whenever the window is resized.
Each card has a front face and a back face on top of each other, both with backface-visibility: hidden, and the back is rotated 180° on the Y axis. The card uses transform-style: preserve-3d inside a stage with perspective. During its flight the card turns 360°, so the back faces the viewer for the middle part of the trip and the photo lands face up.
Each photo starts with a CSS filter of high brightness, low saturation, some sepia, low contrast and a slight blur. A GSAP fromTo tween changes it to a neutral filter while the card flies, so the picture sharpens and gains colour as it lands. Both filter strings list the same functions in the same order, which lets GSAP tween every number in them.
Add a .pf-card (with data-x, data-y and data-r for its place in the pile) and a .pf-slot (with data-r for its tilt on the board), and make sure the board grid has room for it. The timeline gives every card its own unit and the scroll length is based on the number of cards, so no other code changes are needed. Remember to update the total in the counter text.
Yes. Click JSX for a React component, Vue for a Vue 3 SFC or Angular for a standalone component. Build the timeline in a mount effect (gsap.context helps), and revert the context on unmount so the ScrollTrigger pin is removed.
Copy & paste
Source Code
<section class="pf-stage" id="pfStage">
<header class="pf-head">
<span class="pf-kicker">Summer trip · 6 photos</span>
<h2>Sort the pile</h2>
</header>
<p class="pf-count" aria-live="polite"><strong id="pfCount">0</strong> / 6 on the wall</p>
<!-- Where each photo ends up. The script measures these, so the layout is pure CSS. -->
<div class="pf-board" aria-hidden="true">
<span class="pf-slot" data-r="-4"></span>
<span class="pf-slot" data-r="3"></span>
<span class="pf-slot" data-r="-2"></span>
<span class="pf-slot" data-r="2.5"></span>
<span class="pf-slot" data-r="-3"></span>
<span class="pf-slot" data-r="4"></span>
</div>
<!-- The pile: data-x / data-y / data-r = where each photo lies before it is picked up. -->
<div class="pf-pile">
<article class="pf-card" data-x="-10" data-y="6" data-r="-9">
<div class="pf-face pf-front"><span class="pf-tape"></span><div class="pf-photo"><img src="https://picsum.photos/id/1015/480/400" alt="Fjord between granite cliffs"></div><p class="pf-cap">Lysefjord</p></div>
<div class="pf-face pf-back"><p class="pf-note">Day 2. Legs gone, view worth every step.</p><span class="pf-date">Jul '26</span></div>
</article>
<article class="pf-card" data-x="12" data-y="-4" data-r="7">
<div class="pf-face pf-front"><span class="pf-tape"></span><div class="pf-photo"><img src="https://picsum.photos/id/1016/480/400" alt="Red canyon rocks at sunset"></div><p class="pf-cap">Canyon light</p></div>
<div class="pf-face pf-back"><p class="pf-note">Waited an hour for this light. Totally worth it.</p><span class="pf-date">Jul '26</span></div>
</article>
<article class="pf-card" data-x="-4" data-y="-10" data-r="-3">
<div class="pf-face pf-front"><span class="pf-tape"></span><div class="pf-photo"><img src="https://picsum.photos/id/1036/480/400" alt="Tents in snow below mountains"></div><p class="pf-cap">Base camp</p></div>
<div class="pf-face pf-back"><p class="pf-note">Coldest night of my life. Best stars too.</p><span class="pf-date">Aug '26</span></div>
</article>
<article class="pf-card" data-x="8" data-y="10" data-r="11">
<div class="pf-face pf-front"><span class="pf-tape"></span><div class="pf-photo"><img src="https://picsum.photos/id/1039/480/400" alt="Waterfall in a green gorge"></div><p class="pf-cap">The falls</p></div>
<div class="pf-face pf-back"><p class="pf-note">Soaked through. Didn't care one bit.</p><span class="pf-date">Aug '26</span></div>
</article>
<article class="pf-card" data-x="-14" data-y="-2" data-r="5">
<div class="pf-face pf-front"><span class="pf-tape"></span><div class="pf-photo"><img src="https://picsum.photos/id/1043/480/400" alt="Pine forest and granite peaks"></div><p class="pf-cap">Valley floor</p></div>
<div class="pf-face pf-back"><p class="pf-note">Swam in that river. Ice cold, zero regrets.</p><span class="pf-date">Aug '26</span></div>
</article>
<article class="pf-card" data-x="4" data-y="2" data-r="-6">
<div class="pf-face pf-front"><span class="pf-tape"></span><div class="pf-photo"><img src="https://picsum.photos/id/1044/480/400" alt="Hiker by a misty river"></div><p class="pf-cap">Trail's end</p></div>
<div class="pf-face pf-back"><p class="pf-note">Last morning. Already planning the next one.</p><span class="pf-date">Aug '26</span></div>
</article>
</div>
<p class="pf-final">Summer, kept.</p>
<p class="pf-hint" aria-hidden="true">Scroll to sort the pile ↓</p>
</section>
<section class="pf-after">
<h2>All on the wall.</h2>
<p>Scroll back up and the photos come off the board, flip back over and drop onto the pile in reverse.</p>
</section>@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&display=swap');
*{box-sizing:border-box;margin:0;padding:0}
html,body{background:#6b4a2b}
body{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;color:#2b1d12}
.pf-stage{
/* one card width; every size below is derived from it */
--cw:clamp(118px, min(13vw, 19vh), 200px);
position:relative;height:100vh;height:100dvh;overflow:hidden;perspective:1400px;
/* corkboard: two speckle layers over a warm base, with a soft vignette */
background:
radial-gradient(rgba(60,35,15,.22) 1px,transparent 1.6px) 0 0/7px 7px,
radial-gradient(rgba(255,240,210,.14) 1px,transparent 1.6px) 3px 4px/9px 9px,
radial-gradient(ellipse at 50% 40%,#d6b080,#a8794a 92%);
box-shadow:inset 0 0 120px rgba(40,20,5,.55);
}
.pf-head{position:absolute;left:clamp(18px,4vw,48px);top:clamp(16px,4vh,40px);z-index:200}
.pf-kicker{font-size:11px;font-weight:700;letter-spacing:.2em;text-transform:uppercase;color:#5a3a1c}
.pf-head h2{font-family:'Caveat',cursive;font-size:clamp(34px,4vw,52px);font-weight:700;line-height:1;color:#2b1d12;margin-top:4px}
.pf-count{position:absolute;right:clamp(18px,4vw,48px);top:clamp(20px,4.5vh,44px);z-index:200;font-size:13px;font-weight:600;color:#3d2817;
background:rgba(255,250,240,.75);padding:7px 14px;border-radius:99px;box-shadow:0 2px 8px rgba(60,30,10,.2)}
.pf-count strong{font-size:16px}
.pf-board{position:absolute;left:50%;top:54%;translate:-50% -50%;display:grid;
grid-template-columns:repeat(3,calc(var(--cw) * 1.16));grid-template-rows:repeat(2,calc(var(--cw) * 1.42));
gap:clamp(10px,2vw,28px) clamp(14px,3vw,44px)}
/* faint pin holes show where photos will go */
.pf-slot{position:relative}
.pf-slot::after{content:"";position:absolute;left:50%;top:6%;width:6px;height:6px;margin-left:-3px;border-radius:50%;background:rgba(60,35,15,.35)}
.pf-pile{position:absolute;left:50%;top:56%;width:0;height:0}
.pf-card{position:absolute;width:var(--cw);height:calc(var(--cw) * 1.22);margin:calc(var(--cw) * -.61) 0 0 calc(var(--cw) / -2);
transform-style:preserve-3d;box-shadow:0 6px 14px rgba(40,20,5,.3);will-change:transform}
.pf-face{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;border-radius:3px}
.pf-front{background:#fffdf7;padding:7% 7% 0}
.pf-photo{position:relative;aspect-ratio:1/0.86;overflow:hidden;background:#2b2b2b}
.pf-photo img{display:block;width:100%;height:100%;object-fit:cover}
.pf-cap{font-family:'Caveat',cursive;font-size:calc(var(--cw) * .13);font-weight:700;text-align:center;color:#2b1d12;margin-top:5%}
.pf-tape{position:absolute;z-index:2;left:50%;top:-5%;width:42%;height:12%;translate:-50% 0;rotate:-3deg;
background:rgba(250,235,190,.75);box-shadow:0 1px 2px rgba(0,0,0,.12);
-webkit-mask:linear-gradient(90deg,transparent 0 3%,#000 3% 97%,transparent 97%);mask:linear-gradient(90deg,transparent 0 3%,#000 3% 97%,transparent 97%)}
.pf-back{transform:rotateY(180deg);display:flex;flex-direction:column;justify-content:center;gap:10%;padding:12%;
background:repeating-linear-gradient(transparent 0 calc(var(--cw) * .13 - 1px),rgba(90,120,170,.25) calc(var(--cw) * .13 - 1px) calc(var(--cw) * .13)),#fbf7ee}
.pf-note{font-family:'Caveat',cursive;font-size:calc(var(--cw) * .13);font-weight:500;line-height:1.05;color:#1e3a8a;transform:rotate(-2deg)}
.pf-date{align-self:flex-end;font-size:calc(var(--cw) * .07);font-weight:700;letter-spacing:.12em;text-transform:uppercase;color:#b4532a;
border:1.5px solid currentColor;border-radius:4px;padding:2px 6px;transform:rotate(4deg)}
.pf-final{position:absolute;left:50%;bottom:clamp(14px,4vh,36px);translate:-50% 0;z-index:200;opacity:0;
font-family:'Caveat',cursive;font-size:clamp(30px,4vw,48px);font-weight:700;color:#2b1d12;white-space:nowrap}
.pf-hint{position:absolute;left:50%;bottom:22px;translate:-50% 0;z-index:200;font-size:12px;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:#3d2817}
.pf-after{min-height:70vh;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:12px;text-align:center;padding:48px 24px;background:#f6efe3}
.pf-after h2{font-family:'Caveat',cursive;font-size:clamp(34px,4vw,48px)}
.pf-after p{max-width:460px;color:#6b5641;font-size:15.5px;line-height:1.7}
@media (max-width:640px){
.pf-stage{--cw:min(34vw, calc((100dvh - 190px) / 4.6))}
.pf-board{top:57%;grid-template-columns:repeat(2,calc(var(--cw) * 1.14));grid-template-rows:repeat(3,calc(var(--cw) * 1.36));gap:8px 18px}
.pf-pile{top:58%}
.pf-count{top:22px;right:16px;font-size:12px;padding:6px 11px}
.pf-hint{left:20px;translate:none}
}gsap.registerPlugin(ScrollTrigger);
const stage = document.getElementById('pfStage');
const pile = stage.querySelector('.pf-pile');
const cards = gsap.utils.toArray('.pf-card');
const slots = gsap.utils.toArray('.pf-slot');
const countEl = document.getElementById('pfCount');
const hint = stage.querySelector('.pf-hint');
const finalLine = stage.querySelector('.pf-final');
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const n = cards.length;
// Photos start washed out and "develop" as they land, like a real instant photo.
const UNDEVELOPED = 'sepia(0.55) saturate(0.15) brightness(1.6) contrast(0.6) blur(1.5px)';
const DEVELOPED = 'sepia(0) saturate(1) brightness(1) contrast(1) blur(0px)';
const LIFTED = '0px 34px 40px rgba(40,20,5,0.35)';
const RESTING = '0px 6px 14px rgba(40,20,5,0.30)';
// Offset from the pile to the centre of slot i, measured from the real layout.
// Function values + invalidateOnRefresh re-measure it after every resize.
function slotOffset(i) {
const p = pile.getBoundingClientRect(), s = slots[i].getBoundingClientRect();
return { x: s.left + s.width / 2 - p.left, y: s.top + s.height / 2 - p.top };
}
const num = (el, k) => Number(el.dataset[k]) || 0;
// The pile: each card lies where its data attributes say, top card last in the list.
cards.forEach((card, i) => {
gsap.set(card, { x: num(card, 'x'), y: num(card, 'y'), rotate: num(card, 'r'), zIndex: n - i, boxShadow: RESTING });
});
const tl = gsap.timeline({
defaults: { ease: 'none' },
// onUpdate on the timeline itself (not the ScrollTrigger), so the counter follows the smoothed scrub
onUpdate: update,
scrollTrigger: {
trigger: stage,
start: 'top top',
end: () => '+=' + Math.round(window.innerHeight * (n + 1) * 0.7),
pin: true,
scrub: reduceMotion ? true : 0.8,
invalidateOnRefresh: true,
},
});
// Each card gets one unit of the timeline: lift (0-0.25), fly + flip (0.25-0.85), land (0.85-1).
cards.forEach((card, i) => {
const photo = card.querySelector('.pf-photo');
const tape = card.querySelector('.pf-tape');
tl.to(card, { y: () => num(card, 'y') - 46, rotate: 0, rotateX: 16, scale: 1.14, zIndex: 100 + i, boxShadow: LIFTED, duration: 0.25, ease: 'power1.out' }, i)
.to(card, {
x: () => slotOffset(i).x,
y: () => slotOffset(i).y,
rotate: () => num(slots[i], 'r'),
rotateX: 0,
rotateY: reduceMotion ? 0 : 360, // a full turn: the handwritten back shows halfway through
scale: 1,
duration: 0.6,
ease: 'power1.inOut',
}, i + 0.25)
.to(card, { boxShadow: RESTING, duration: 0.15 }, i + 0.72)
.fromTo(photo, { filter: UNDEVELOPED }, { filter: DEVELOPED, duration: 0.55 }, i + 0.45)
.fromTo(tape, { opacity: 0, scale: 0.5 }, { opacity: 1, scale: 1, duration: 0.12, ease: 'back.out(2.5)' }, i + 0.84);
});
tl.fromTo(finalLine, { opacity: 0, y: 16 }, { opacity: 1, y: 0, duration: 0.5 }, n + 0.05)
.to({}, { duration: 0.35 }); // a short hold on the finished wall
function update() {
const time = tl.time();
let landed = 0;
for (let i = 0; i < n; i++) if (time >= i + 0.84) landed++;
countEl.textContent = landed;
hint.style.opacity = time > 0.05 ? 0 : 1;
}
update();Extend with AI
Take This Snippet Further With AI
You do not need to work out 3D card flips and scrubbed timelines from scratch. Paste this snippet's HTML, CSS and JS into an AI assistant like Claude and ask it how the two faces and backface-visibility make the flip work, why the tween values are functions, or how GSAP can tween a whole filter string. It can also help you extend it: let visitors click a photo on the wall to open it larger, add a pushpin or a paper clip as an alternative to tape, shuffle the board layout on each visit, or load the photos and notes from a JSON file.
Prompt to recreate it
Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:
Build a scroll-driven "polaroid pile sorts onto a corkboard" section in HTML, CSS and JavaScript using GSAP and ScrollTrigger from a CDN.
Requirements:
- A full-screen pinned stage with a corkboard background made of CSS gradients (two speckle layers over a warm base, inset shadow) and perspective: 1400px. A small header ("Sort the pile"), a counter ("0 / 6 on the wall") and a scroll hint.
- An invisible board: a CSS grid of 6 empty slots (3 x 2, or 2 x 3 on phones), each with a data-r tilt.
- A pile of 6 polaroid cards at one point, each placed by data-x, data-y and data-r. Each card has transform-style: preserve-3d and two faces with backface-visibility: hidden: the front (white frame, photo, handwritten caption in the Caveat font, a strip of tape) and the back (lined paper, a handwritten note, a date stamp), rotated 180deg on Y.
- Size everything from one --cw custom property based on screen width and height.
- One GSAP timeline with a pinned ScrollTrigger (scrub about 0.8, end based on the number of cards, invalidateOnRefresh: true). Each card gets one unit: lift (y -46, scale 1.14, rotateX 16, deeper box-shadow, z-index on top), then fly to its slot (x and y as functions that measure the slot centre relative to the pile with getBoundingClientRect, rotate to the slot tilt, rotateY 360 so the back shows mid-flight, scale 1), then the tape pops in.
- The photo filter tweens from an "undeveloped" string (sepia, low saturation, high brightness, low contrast, slight blur) to neutral while the card flies, so it develops as it lands.
- Update the counter as each card lands, fade the hint once scrolling starts, and fade in a handwritten closing line after the last card.
- With prefers-reduced-motion, skip the rotateY flip and use scrub: true. Scrolling back up must reverse everything.Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.