InputLightweight
Scroll & viewport
Knowing what is on screen and how far you scrolled.
Knowing how far the page has scrolled and which sections are on screen. It starts and stops scenes as they come into view and turns scroll position into a number other effects can use.
- Breaks when
- iOS rubber-banding gives negative scroll
- Also called
- IntersectionObserver, ScrollControls, in-view
Prompts
Sections that wake their scenes
Three canvases on one page, each managed by an IntersectionObserver with threshold [0, 0.5, 1] and rootMargin 20%: a scene starts its loop at 0.5 visibility, pauses at 0, and preloads assets at the 20% margin. Show the intersection ratio and state in a debug corner. Never run more than one loop at a time.
One number from scroll
Turn document scroll into a normalized progress for a pinned section (0 when its top hits the viewport top, 1 when its bottom does), smoothed with an exponential damp and exposed as a CSS variable and a JS value. Handle iOS overscroll (clamp negatives), the address-bar resize (ignore height changes under 120 px), and prefers-reduced-motion (snap instead of smooth).
drei ScrollControls done right
R3F with <ScrollControls pages={3} damping={0.25}>: useScroll’s range() and curve() drive three object animations; HTML overlays via <Scroll html>. Explain the difference between range and curve, and how to keep DOM scroll native so accessibility tools still work.Related
Resources · 1
- Lenis smooth scrollPair with ScrollTrigger; fixes scrub jank.darkroomengineeringGitHub · code · demoAug 3, 2026