Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Scroll-Driven Animation: Timelines, View Ranges, and Fallbacks

How Scroll Timelines and View Timelines link CSS animations to scroll position, with ranges, patterns, feature detection, and fallbacks.

This page summarizes Chrome for Developers documentation on scroll-driven animations: declarative effects tied to scroll position instead of clock time, so motion stays in sync with scrolling and can run off the main thread when the browser supports the feature.

A scroll-driven animation is linked to the scroll position of a scroll container. This means that as you scroll up or down, the linked animation scrubs forward or backward in direct response.

— Chrome, Animate elements on scroll with Scroll-driven animations

Classic scroll event handlers on the main thread are a poor fit for that goal: scrolling often happens on a separate process, scroll events arrive asynchronously, and main-thread animation tends to jank. Scroll-driven animations integrate with the CSS Animations API and Web Animations API (WAAPI) so linked animations can inherit compositor-friendly behavior.

Scroll Timeline and View Timeline: what each timeline measures

Section titled “Scroll Timeline and View Timeline: what each timeline measures”

The Scroll-driven Animations Specification defines two timeline types beyond the default document timeline.

Timeline Tied to Typical use
Scroll Progress Timeline (“Scroll Timeline”) Progress along a scroll container’s scroll range (0% at start, 100% at end) Reading progress bar, horizontal carousel step indicator
View Progress Timeline (“View Timeline”) How a subject moves through its nearest scrollport (enter → leave) Fade-in on scroll, entry/exit effects, parallax layers

A View Progress Timeline begins from the moment a subject starts intersecting with the scroller and ends when the subject stops intersecting the scroller.

— Chrome, Animate elements on scroll with Scroll-driven animations

View timelines are conceptually similar to IntersectionObserver, but drive animation progress rather than only reporting intersection.

Chrome documents baseline support as Chrome 115, Edge 115, Firefox 159, and Safari 26 on the scroll-driven animations overview. Treat older engines as needing progressive enhancement or JavaScript fallbacks.

animation-timeline: scroll() and named Scroll Timelines

Section titled “animation-timeline: scroll() and named Scroll Timelines”

The scroll() function creates an anonymous Scroll Timeline for animation-timeline:

@keyframes grow-progress {
from { transform: scaleX(0); }
to { transform: scaleX(1); }
}
#progress {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 1em;
transform-origin: 0 50%;
animation: grow-progress auto linear;
animation-timeline: scroll();
}

Because an animation-duration set in seconds does not make sense when using a Scroll Progress Timeline, you must set animation-duration to auto.

— Chrome, Animate elements on scroll with Scroll-driven animations

scroll() arguments pick the scroller (nearest, root, self) and axis (block, inline, x, y). Defaults are nearest and block. For a fixed progress bar on the page, scroll() with no arguments often resolves to the root scroller in the block direction, as in Build a Scroll Progress Indicator.

When the animated element is not a descendant of the scroller in the containing-block chain—as with an absolutely positioned progress bar over a horizontal gallery—use a named timeline on the scroller and reference it from the animated element:

.gallery__scrollcontainer {
overflow-x: scroll;
scroll-timeline: --gallery__scrollcontainer inline;
}
.gallery__progress {
animation: auto grow-progress linear forwards;
animation-timeline: --gallery__scrollcontainer;
}

Chrome explains that animation-timeline: scroll(nearest inline) on the progress element may miss the inner scroller because nearest walks the containing-block chain, not only the DOM parent chain (horizontal carousel demo).

To animate a non-ancestor sibling using the same named timeline, hoist visibility with timeline-scope on a shared parent (Attaching to a non-ancestor Scroll Timeline).

animation-timeline: view() and View Timeline ranges

Section titled “animation-timeline: view() and View Timeline ranges”

view() binds animation progress to the element’s visibility in its nearest parent scroller:

@keyframes reveal {
from { opacity: 0; }
to { opacity: 1; }
}
img {
animation: reveal linear;
animation-timeline: view();
}

It is not possible to determine the <scroller> of a View Timeline, as it always tracks the subject within its nearest parent scroller.

— Chrome, Animate elements on scroll with Scroll-driven animations

For horizontal carousels, use view(inline) (carousel slide effects).

animation-range: entry, exit, cover, and shorthand

Section titled “animation-range: entry, exit, cover, and shorthand”

By default, a view-linked animation can span the full visibility range. animation-range limits which segment runs—for example only while entering:

Range name Meaning (simplified)
entry Subject entering the scrollport
exit Subject leaving the scrollport
cover Full view progress range
contain Fully contained or fully covering the scrollport (size-dependent)

Example from image reveal:

.revealing-image {
animation: auto linear reveal both;
animation-timeline: view();
animation-range: entry 25% cover 50%;
}

Entry and exit on one element use two animations and comma-separated ranges (scroll entry/exit effects):

.animated-element {
animation:
slide-in auto linear backwards,
slide-out auto linear forwards;
animation-timeline: view();
animation-range: entry, exit;
}

When start and end use the same range name from 0% to 100%, shorthand works: animation-range: entry equals entry 0% entry 100%.

Ranges use the untransformed principal box, so scaling during scroll does not constantly reshuffle range boundaries—a deliberate spec behavior noted in Chrome’s View Timeline ranges section.

Scroll-driven patterns: progress, parallax, and scrollytelling

Section titled “Scroll-driven patterns: progress, parallax, and scrollytelling”

Prefer compositor-friendly properties: animate transform: scaleX() rather than width (reading progress demo). Purely decorative bars should use aria-hidden="true" on the progress node (scroll progress indicator guide).

Parallax on scroll ties layer motion to a wrapper’s view timeline and staggers depth via animation-range or sibling-index() in keyframes.

Scrollytelling names view timelines on tracked sections, declares timeline-scope on a common ancestor (often html), and attaches animations on a separate animated layer with tuned animation-range pairs for in and out.

A fixed header can use animation-timeline: scroll(block root) and pixel-based animation-range (e.g. 0px 150px). Chrome warns the animated header should not be position: static or relative when using percentage ranges in animation-range, because in-flow height changes alter total scroll distance (shrinking header).

JavaScript: ScrollTimeline and ViewTimeline

Section titled “JavaScript: ScrollTimeline and ViewTimeline”

CSS and JS share the same concepts. Create timelines and pass them to element.animate() without a time-based duration:

const tl = new ScrollTimeline({
source: document.documentElement,
});
document.querySelector('#progressbar').animate(
{ transform: ['scaleX(0)', 'scaleX(1)'] },
{ fill: 'forwards', timeline: tl },
);

View timelines accept subject, axis, and inset; range endpoints use rangeStart / rangeEnd (e.g. 'entry 25%, 'cover 50%'). The animated element and the tracked subject need not be the same node (View Timeline in JavaScript).

Feature detection, accessibility, and fallbacks

Section titled “Feature detection, accessibility, and fallbacks”

Guides differ slightly by pattern:

  • Scroll-timeline effects: @supports (animation-timeline: scroll()) or stricter checks including animation-range where partial support exists.
  • View-timeline entry/exit: @supports ((animation-timeline: view()) and (animation-range: entry)) — Chrome states the animation-range: entry check MUST be included to filter partial implementations (entry/exit effects best practices).

In supporting browsers, always prefer native CSS; fallbacks are typically IntersectionObserver (view-like effects) or scroll listeners (scroll-position effects). Not every native effect reproduces faithfully in script.

Wrap enhancements in @media (prefers-reduced-motion: no-preference) and disable or simplify motion under prefers-reduced-motion: reduce. Animate transform and opacity when possible for compositor performance; avoid animating width, height, or layout-heavy properties during scroll.

Decorative-only motion can use progressive enhancement without a fallback.

Section titled “Related scroll features (when timelines are not enough)”

These cluster documents solve adjacent problems without replacing scroll-driven animations:

  • position: sticky has no stickiness event — sentinel nodes plus IntersectionObserver can synthesize a sticky-change custom event (sticky headers article).
  • scroll-target-group and :target-current — native scrollspy styling (scrollspy).
  • scrollsnapchange / scrollsnapchanging — sync UI with snap targets during and after gestures (scroll snap state sync).
  • Container scroll-state queries — style by stuck, snapped, or scrollable edges without scroll listeners (state-aware sticky headers).
  • scrollend — run heavy work when scrolling has fully stopped instead of debouncing scroll (defer work until scroll ends).

For passive scroll listeners when you must use them, see passive event listeners.

  1. Putting animation-timeline inside the animation shorthand and wondering why the timeline reset.
  2. Using view() on the block axis for a horizontal scroller instead of view(inline).
  3. Expecting scroll(nearest) to find a scroller that only affects layout through absolute positioning—use a named scroll-timeline instead.
  4. Forgetting animation-duration: auto (or auto in the shorthand) for scroll/view timelines.
  5. Shipping the scroll-timeline polyfill despite documented gaps.
  6. Animating layout properties on scroll-linked effects and getting jank or feedback loops on in-flow headers.
  1. Open a page that uses animation-timeline in a supported browser (see scroll-driven animations) and confirm the effect tracks scroll smoothly with no main-thread stutter.
  2. Temporarily remove or break animation-timeline in DevTools and verify your @supports gate hides the effect and any fallback (if provided) behaves acceptably.
  3. Enable Reduce motion at the OS level and confirm animations disable or simplify per your prefers-reduced-motion rules (entry/exit guide).
  4. For view ranges, compare on-page behavior with the View Timeline Ranges Visualizer using the same animation-range values.
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about.