Rendering PipelineExperimental

Scroll-Driven Animations

Mental Model

Scroll-Driven Animations replace scroll event listeners with native timelines: scroll() tracks a container's scroll offset, while view() tracks an element's visibility inside its scrollport. Both run on the Compositor Thread at full display refresh rate.

Interactive Simulator

JS scroll Listener vs animation-timeline: scroll()

Compare main-thread scroll progress bars against native CSS scroll timelines.

Lines of Code
Before
4
After
6
Reflows / Browser Cost
Before
1 Layout+Paint per scroll tick
After
0 (Compositor Thread)
BeforeJS scroll Event + style.width
window.addEventListener('scroll', () => {
  const max = document.body.scrollHeight - innerHeight;
  bar.style.width = `${(scrollY / max) * 100}%`;
}, { passive: true });
Lines: 4Reflows: 1 Layout+Paint per scroll tickDependencies: Main-thread listener

Janks during main-thread work and lags behind async touch scrolling.

After (Native)CSS animation-timeline: scroll()
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.progress-bar {
  transform-origin: left;
  animation: grow linear both;
  animation-timeline: scroll(root block);
}
Lines: 6Reflows: 0 (Compositor Thread)Dependencies: 0 JS

Locked to compositor scroll offset with zero main-thread involvement.

Under the Hood

A JS scroll listener is a backseat driver shouting coordinates over a walkie-talkie; animation-timeline wires the speedometer directly to the axle.

  1. Timeline Replacement: Instead of wall-clock time, Web Animations API timelines sample progress from 0% to 100% based on scroll offset.
  2. Compositor Execution: When animating GPU Compositor Layers properties like transform: scaleX() or opacity, the Compositor Thread updates pixels without waking the main thread.
  3. Named Ranges: animation-range: entry 0% cover 40% scopes view() animations to exact entry and exit phases.
CSS
@supports (animation-timeline: view()) {
  .reveal-card {
    animation: fade-slide linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
  }
}

Problem Genealogy

  • 2013–2022: Parallax and reading-progress bars relied on throttled scroll handlers or IntersectionObserver + rAF, lagging one frame behind async compositor scrolling.
  • 2023+: CSS Scroll-Driven Animations introduced scroll() and view() timelines in Chromium, with Safari 26 following and Firefox implementing.

Production Pitfalls

Production Pitfall
  • Missing @supports guard: Setting opacity: 0 at 0% leaves elements permanently invisible in browsers lacking animation-timeline support.
  • Animating width instead of scaleX(): Using width forces Layout on every scroll tick, forfeiting compositor offloading.
When Not to Use
  • When not to use Scroll-Driven Animations: Do not use them for critical navigation state or binary sticky-header triggers where IntersectionObserver or position: sticky suffices.

Connections & Logical Next Steps

Rendering PipelineScroll-Driven Animations
What This Unlocks
Leaf concept

Seen in Architecture Autopsies

Mechanical Comparisons