Purpose: Step-by-step implementation of scroll-linked image sequence animations
Last Updated: 2026-01-07
npm i framer-motion)Use nano banana or AI image tools to create start/end frames, then generate interpolation:
Start frame prompt:
Ultra-premium product photography of [product] on matte black surface,
minimalistic studio shoot, deep black background with subtle gradient,
soft rim lighting, cinematic, high contrast, luxury aesthetic, sharp focus,
no clutter, DSLR 85mm f/1.8, photorealistic
End frame prompt:
Exploded technical diagram of same [product], every component separated
and floating in alignment, against deep black studio background, visible
internal structure, hyper-realistic, studio rim lighting, cinematic,
high contrast, no labels, photorealistic
Generate video: Use AI video tools (Runway, Pika) to interpolate between frames.
Export frames: Use ffmpeg or ezgif to split video into 120+ WebP images.
ffmpeg -i animation.mp4 -vf fps=30 frame_%04d.webp
app/
├── page.tsx # Main landing page
├── components/
│ └── HeadphoneScroll.tsx # Scroll animation component
└── globals.css # Dark theme, Inter font
public/
└── frames/
├── frame_0001.webp # 120+ frames
├── frame_0002.webp
└── ...
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
body {
@apply bg-[#050505] text-white antialiased;
font-family: 'Inter', -apple-system, sans-serif;
}
}
Key patterns:
h-[400vh] for long scrollsticky top-0 stays fixeduseScroll tracks scroll progress (0-1)useTransform maps progress to frame indexuseEffect preloads all imagesCore logic:
const { scrollYProgress } = useScroll({ target: containerRef })
const frameIndex = useTransform(scrollYProgress, [0, 1], [0, 119])
Always preload images before starting animation:
useEffect(() => {
const loadImages = async () => {
const promises = Array.from({ length: 120 }, (_, i) => {
return new Promise((resolve) => {
const img = new Image()
img.src = `/frames/frame_${String(i + 1).padStart(4, '0')}.webp`
img.onload = () => resolve(img)
})
})
const loaded = await Promise.all(promises)
setImages(loaded)
setLoading(false)
}
loadImages()
}, [])
Draw current frame to canvas on every scroll update:
useEffect(() => {
if (!canvasRef.current || !images.length) return
const canvas = canvasRef.current
const ctx = canvas.getContext('2d')
const img = images[Math.round(currentFrame)]
// Scale canvas to window
canvas.width = window.innerWidth
canvas.height = window.innerHeight
// Draw centered
ctx.drawImage(img,
(canvas.width - img.width) / 2,
(canvas.height - img.height) / 2
)
}, [currentFrame, images])
Fade text in/out at specific scroll positions:
<motion.div
style={{
opacity: useTransform(scrollYProgress,
[0.25, 0.30, 0.35], // Fade in 25-30%, out 35%
[0, 1, 0]
)
}}
className="absolute left-20 text-4xl font-bold"
>
Precision Engineering.
</motion.div>
CRITICAL: Page background MUST match image background exactly.
#050505)// Add GPU hint
<canvas
ref={canvasRef}
className="sticky top-0 h-screen w-full"
style={{ willChange: 'transform' }}
/>
// Throttle redraws on mobile
useEffect(() => {
let rafId
const render = () => {
// Draw logic here
rafId = requestAnimationFrame(render)
}
render()
return () => cancelAnimationFrame(rafId)
}, [])
Show spinner while frames load:
{loading && (
<div className="fixed inset-0 flex items-center justify-center bg-[#050505]">
<div className="animate-spin h-12 w-12 border-4 border-white/20 border-t-white rounded-full" />
</div>
)}
/public/frames/