Cinematic Scroll-Coupled Web Skill
Build zero-dependency, 60fps continuous-scroll interactive web experiences where every visual layer—camera zoom, SVG morphing, particle scatter, wind physics, and narrative/sales copy—shares a single normalized scroll coordinate (position in [0, 1]).
Architecture Overview
Every page follows a four-layer sticky stage inside a tall scroll track:
#track (height: 700vh, creates natural scroll distance)
└── #viewport (position: sticky; top: 0; height: 100vh; overflow: hidden)
├── #sky / ambient background layers (color & mood interpolation)
├── #world (isolated stage: hero centerpiece, SVG filters, particles, atmosphere)
├── #rail (position: absolute; N stacked 100vh chapters translated continuously)
└── #texture / HUD (#bar, #meter, #guide, sticky CTA bar for e-commerce)
- Never toggle discrete slides with classes alone. Drive
#railviatranslate3d(0, ${-position * (N - 1) * innerHeight}px, 0)and interpolate all scene transitions with smoothstep (smooth(a, b, position)). - Keep
#worldand#railnon-blocking (pointer-events: none) except on explicit interactive elements (#overlay button, variant swatches, Buy/Cart CTAs) which must setpointer-events: autoand higherz-index.
Build Workflow
- Choose the Domain Mode:
- Storytelling / Manga: Follow Physics & SVG Engine and start from starter-template.html.
- Product Showcase / E-Commerce: Follow E-Commerce Adaptation Guide and study ecommerce-product-showcase.html.
- Design the Layered Hero SVG:
- Build the hero centerpiece (character, emblem, or product hardware) inside a single normalized
viewBoxwith named<g>layers so individual sub-parts can rotate, explode apart, zoom, or swap colorway independently.
- Build the hero centerpiece (character, emblem, or product hardware) inside a single normalized
- Wire the Spring-Lerp Loop (
requestAnimationFrame):- Compute
target = clamp(-track.getBoundingClientRect().top / maxScroll, 0, 1). - Ease
position += (target - position) * 0.115and derive smoothedspeedand boundedimpulse(wind) so fast scrolling naturally drives cloth, hair, particles, and SVG displacement filters.
- Compute
- Choreograph the 6-Stage Arc:
- Map
0.00 -> 1.00across 6 evenly spaced100vh.chaptersections (top: 0throughtop: 500vh). - Pair progressive zoom (
scale) and layer crossfades (smooth(a, b, position)) with concise.captioncards and a top#bar+#meterHUD.
- Map
- Verify Before Shipping:
- Serve over local HTTP and test
00%,25%,50%,75%, and100%scroll positions. - Confirm interactive overlays (
#enter), variant selectors, and sticky CTAs remain clickable (pointer-events: auto). - Confirm zero console errors, readable text contrast across bright focal elements, and clean framing at both desktop (
1280x800) and mobile (390x844) viewports.
- Serve over local HTTP and test
Critical SVG & CSS Pitfalls
Avoid these common failure modes when building SVG-heavy scroll pages:
- CSS
#id { opacity: 0 }blockssetAttribute('opacity', ...): ID selectors in CSS override SVG presentation attributes. Either omitopacity: 0in CSS (use SVG attributeopacity="0"initially +setAttribute('opacity', ...)) or updateel.style.opacityin JS. - SVG
transformattributes ignore CSStransform-origin:transform-box: fill-box; transform-origin: ...applies only to CSSel.style.transform. For SVGsetAttribute('transform', ...), explicitly wrap rotations/scales around center(cx, cy):translate(cx cy) rotate(deg) scale(s) translate(-cx -cy). - Use Cubic Bézier Curves (
C) Instead of Spiky Wedges: For organic hair, ribbons, cloth, smoke, or liquid trails, avoid triangularLspikes and large CSSskewXdistortions. Animate cubic Bézier control points smoothly with sine-wave offsets alongphaseand clampedwind. - Lock Hero Wrapper Aspect Ratio to
viewBox: Give the hero SVG containeraspect-ratio: <W>/<H>; height: auto;(instead of mixing independentvwandvhdimensions) sotransform-originzoom coordinates stay locked on target across all screen sizes. - Prevent Mid-Screen Atmospheric Seams:
Do not close mid-screen fog/mist
<path>shapes along a flat horizontal line (L1440 490 ... Z) with a visible stroke. Usestroke: noneand close cloud bands smoothly below the viewport or with undulating bottom curves. - Guard Text Contrast Over Luminous Focal Areas:
Apply layered dark drop-shadows (
text-shadow) on large display titles and dark translucent cards (backdrop-filter: blur(4px)) on captions so copy stays legible even when passing over bright moons, glows, or metallic product highlights.
References & Examples
- Physics & SVG Engine — Spring-lerp math,
smooth(), reactive SVG filters, concentric rotations, traveling Bézier waves, and particle scatter formulas. - E-Commerce Adaptation Guide — Adapting the 6-chapter arc to product launches, exploded views, colorway switching, spec callouts, and sticky buy bars.
- Starter Template — Clean 6-stage continuous-scroll scaffold ready for any theme.
- E-Commerce Product Showcase — Full working luxury timepiece / hardware product launch demo built with this engine.