How it works
Animations that run on scroll instead of time
A CSS animation normally advances with the clock. Give it a scroll or view timeline instead and its progress becomes a position: how far a container is scrolled, or where an element is on its way through the scrollport. The browser does the bookkeeping; no script listens to scroll.
1. A view timeline per element: view()
animation-timeline: view() replaces the document clock with an anonymous view progress timeline: the element's position relative to the scrollport of its
nearest scroll container. Here that is the stage, not the page; the page layout keeps the
stage fixed, so the stage itself is the scroller. The animation's duration becomes
irrelevant, its keyframes are spread over the element's trip through the scrollport.
2. Which part of the trip: animation-range
A view timeline has named ranges. entry runs from the moment the element's
leading edge enters the scrollport until it is fully inside (or fills it, if it is taller). exit is the same at the other end. cover spans the whole trip,
from the first visible pixel to the last; contain only the part where the
element is completely visible; entry-crossing the time its leading edge needs
to cross the scrollport's end edge. Percentages trim a range: entry 20% entry 80% starts the reveal a little late and finishes it before the element
is fully in.
The Span setting picks a range for you. center (the default) runs from entry 0% to cover 50%: the reveal starts with the first visible
pixel and finishes when the element's middle reaches the middle of the scrollport, so it
plays over half a screen of scrolling and is easy to follow. entry is quicker:
done the moment the element is fully in, often while it is still at the bottom edge. visible reveals on entry and hides again on exit; custom uses the range
and percentages below it.
A catch: center, cover and contain end after the element
has fully entered. The last element in a scroller may never get there, because the scroller can't
scroll it far enough. With those ranges, leave room after the last element; the stage here ends
with padding for that reason.
3. Keyframes that start hidden
The keyframes start from the hidden state (shifted in from an edge and transparent, turned
away in 3D, shrunk, clipped or blurred) and end on the element's normal styles. animation-fill-mode: both holds the first keyframe until the range starts and the last after it ends, so cards below the
fold wait hidden and stay revealed when you scroll back. The presets animate opacity, translate, scale, filter, clip-path and transform from one set of custom properties, so a
single @keyframes rule serves all of them. A clip reveal ends on inset(0) rather than none: the two can't be interpolated, so the
animation would jump. A flip ends on the same perspective() it starts with, at 0°,
for the same reason.
A slide from the side moves the element past the scroller's edge while it runs, which widens
the scrollable area and brings up a horizontal scrollbar. The scroller here has overflow: hidden auto; clip would be nicer, but next to auto it turns into hidden anyway.
Hide on exit (always on for the visible span) adds the same keyframes
a second time, reversed, on the exit range. That second animation fills only forwards: filling
backwards as well would hold its first frame (fully visible) over the whole entry and
override the reveal, since later animations in the list win.
@keyframes reveal {
from {
opacity: 0;
translate: 160px 0;
}
}
/* without support or with reduced motion, nothing hides */
@supports (animation-timeline: view()) {
@media (prefers-reduced-motion: no-preference) {
.reveal {
animation: reveal ease-out both;
/* after the shorthand, which resets it */
animation-timeline: view();
animation-range: entry 0% cover 50%;
}
}
} 4. Named timelines: parallax and the progress bar
A parallax layer can't use its own view(): it is oversized and it is the thing
that moves. Instead the scene declares a named timeline, view-timeline: --vfx-parallax block, and every layer inside refers to it by
name. Each layer then moves from −depth × strength to +depth × strength while the scene crosses the scrollport: positive depths move with
the scroll and so lag behind it (far away), negative ones against it (in front), depth 0 not at
all. Layers are oversized by their travel, so their edges never show.
.scene {
position: relative;
overflow: clip;
/* a named view timeline the layers can refer to */
view-timeline: --scene block;
}
@keyframes parallax {
from { translate: 0 calc(var(--depth) * -480px); }
to { translate: 0 calc(var(--depth) * 480px); }
}
@supports (animation-timeline: view()) {
@media (prefers-reduced-motion: no-preference) {
.layer {
animation: parallax linear both;
animation-timeline: --scene;
animation-range: cover;
}
}
} The progress bar uses a scroll progress timeline: how far the stage is scrolled, 0% at the
top and 100% at the bottom. It sits above the scroller, not inside it, so scroll(nearest) wouldn't find the stage. The scroller names its timeline (scroll-timeline: --vfx-stage block) and a common ancestor declares timeline-scope: --vfx-stage, which makes the name visible to the scroller's
siblings. The bar scales from 0 1 to 1 1, a compositor-only
property.
.stage {
/* lets a sibling of the scroller see its timeline */
timeline-scope: --stage;
}
.scroller {
overflow: hidden auto;
scroll-timeline: --stage block;
}
@keyframes progress {
from { scale: 0 1; }
to { scale: 1 1; }
}
.progress {
display: none;
block-size: 4px;
background: #a78bfa;
transform-origin: 0 50%;
}
@supports (animation-timeline: scroll()) {
.progress {
display: block;
animation: progress linear both;
animation-timeline: --stage;
}
} 5. Fallback and motion
All animation rules sit inside @supports (animation-timeline: view()) and @media (prefers-reduced-motion: no-preference). Since the hidden state exists
only as a keyframe, a browser that doesn't apply the animation shows the content as is: no
IntersectionObserver fallback, nothing to hide first and reveal later. Reduced motion
switches reveals and parallax off the same way. The progress bar stays, because it only
moves as the reader scrolls, and is hidden only where it can't work. A [data-motion="paused"] region also switches the reveals off: pausing a scroll-driven
animation would freeze it wherever it is, possibly invisible.
Browser support
Scroll-driven animations are not Baseline: Chrome and Edge support them since 115 and Safari
since 26, Firefox doesn't (per the web-features data, see the webstatus.dev entry).
In Firefox this page shows all content statically. Chrome 146 adds scroll-triggered animations (animation-trigger), which play a time-based animation once a scroll
position is crossed; they are Chromium-only and not used here. Tested in Chromium 156 only;
Safari, including its support for timeline-scope used by the progress bar, is untested.
Performance notes
- Transforms and opacity stay off the main thread. When a scroll-driven
animation only touches
transform,translate,scaleoropacity, the compositor can run it in sync with scrolling, even while the main thread is busy. Fade-up, scale and parallax are of that kind. - Blur and clip-path repaint. A
filter: blur()has to be redrawn for every scroll step while it animates, and costs more the larger the blur and the element (an estimate, not measured here). Use the blur preset on a few elements, not a whole list. - Nothing runs when nothing scrolls. There is no listener or observer; an idle page does no work.