Scroll-driven Animations and View Transitions (Web platform)
Two extensions of the Web Animations model that replace its inputs: Scroll-driven Animations swap the time source for a scroll position (ScrollTimeline, ViewTimeline, animation-timeline, animation-range), so progress is a percentage and no clock is involved; View Transitions swap the targets for UA-generated pseudo-elements that paint a raster snapshot of the old DOM and a live capture of the new one, so the DOM can change instantly while the visual change animates — including elements that no longer exist.
| Field | Value |
|---|---|
| Language | CSS (animation-timeline, scroll(), view(), animation-range, view-transition-name, view-transition-class, @view-transition, ::view-transition-*) and WebIDL (ScrollTimeline, ViewTimeline, document.startViewTransition, ViewTransition) |
| License | W3C Software and Document License (LICENSE.md) |
| Repository | w3c/csswg-drafts: scroll-animations-1, css-view-transitions-1, css-view-transitions-2 |
| Documentation | Scroll-driven Animations (TR) · CSS View Transitions 1 (TR) · CSS View Transitions 2 (TR) · MDN only as secondary (View Transition API, scroll-driven animations) |
| Category | Scroll-driven: progress-based timelines feeding ordinary keyframe effects. View Transitions: UA-captured snapshots of the previous frame, animated by CSS Animations on a pseudo-element tree above the page |
| Versions surveyed | w3c/csswg-drafts commit 9c7ee53 (2026-11-25): Scroll-driven Animations ED (last TR WD 2023-04-28), View Transitions 1 ED (FPWD 2022-10-25; last CRD 2024-03-28), View Transitions 2 ED (last TR WD 2024-05-16) |
| Animation state lives in | Scroll-driven: the scroll offset of a scroll container (the timeline is the scroll position); the Animation objects are ordinary. View Transitions: the UA's ViewTransition object — its named elements map of captured elements (old image, old geometry, new element), the pseudo-element tree, and the CSS Animations running on it |
NOTE
The underlying timing model, effect stacks and FLIP are on Web Animations; the CSS animation front ends that drive both features here are on CSS Transitions and Animations. Quotes are verbatim from the Bikeshed sources at commit 9c7ee53, linked to line ranges, with the rendered section alongside.
Overview
What it solves
Scroll-driven Animations let a scroll position drive animation progress without script on every scroll event: "These scroll-driven animations use a timeline based on scroll position, rather than one based on clock time. This module provides both an imperative API building on the Web Animations API as well as a declarative API building on CSS Animations" (§ Introduction). It is explicitly about progress, not triggering: "Scroll-driven animations, whose progress is linked to the scroll position, are distinct from scroll-triggered animations, which are triggered by a scroll position, but whose progress is driven by time" (same).
View Transitions solve the problem that animating between two DOM states used to require both states to be in the DOM at once (§ Separating Visual Transitions from DOM Updates):
"Traditionally, creating a visual transition between two document states required a period where both states were present in the DOM at the same time. […] This extra in-between state often resulted in UX and accessibility issues, as the structure of the DOM was compromised for a purely-visual effect. View Transitions avoid this troublesome in-between state by allowing the DOM to switch between states instantaneously, then performing a customizable visual transition between the two states in another layer, using a static visual capture of the old state, and a live capture of the new state."
Design philosophy
- Replace the input, keep the model. Scroll-driven Animations "extend the Web Animations model by defining scroll-driven timelines" (§ Relationship to other specifications); View Transitions animate pseudo-elements with ordinary CSS Animations and Web Animations (§ View Transition Customization).
- Compatible with off-main-thread scrolling. "this specification allows expressing scroll-driven effects in a way that does not require script to run each time the effect is sampled. User agents that support asynchronous scrolling are allowed (but not required) to sample such effects asynchronously as well" (§ Relationship to asynchronous scrolling).
- A transition is an enhancement, never a gate. "an animated transition is a visual enhancement to an underlying document state change. That means a failure to create a visual transition […] will not prevent the developer's ViewTransitionUpdateCallback being called" (§ Transitions as an enhancement).
- Visual identity is a name, not a node. Two elements with the same
view-transition-namein the old and new states "are treated as representing different visual state of the same element […] it is a useful model to consider them to be visual states of the same conceptual page entity" (view-transition-name).
How it works: Scroll-driven Animations
Scroll progress timelines
"Scroll progress timelines are timelines linked to progress in the scroll position of a scroll container along a scrollable axis. The startmost scroll position represents 0% progress and the endmost scroll position represents 100% progress" (§ Scroll Progress Timelines). Progress is a ratio, not a time: "scroll offset ÷ (scrollable overflow size − scroll container size)", and a zero denominator makes the timeline inactive (§ Calculating Progress). In script it is new ScrollTimeline({ source, axis }) with axis one of block, inline, x, y (ScrollTimeline); in CSS it is anonymous scroll() or a named scroll-timeline. Web Animations Level 2 supplies the model change: a non-monotonic timeline is a progress-based timeline whose duration is 100%, and currentTime is "expressed as a percentage for a progress-based timeline" (Web Animations 2 § Timelines, AnimationTimeline).
View progress timelines
"View progress timelines are segments of a scroll progress timeline that are scoped to the scroll positions in which any part of the subject element's principal box intersects its nearest ancestor scrollport" (§ View Progress Timelines). They define named ranges — cover, contain, entry, exit, entry-crossing, exit-crossing (§ View Progress Timeline Ranges) — and in script are new ViewTimeline({ subject, axis, inset }) (ViewTimeline).
Attaching animations: animation-timeline, animation-range
animation-timeline (from CSS Animations 2) takes auto, none, a timeline name, scroll() or view() (animation-timeline). animation-range clips the animation's active interval to part of the timeline: "animation-range: entry 10% exit 90%" expands to animation-range-start: entry 10%; animation-range-end: exit 90% (animation-range). The spec's reveal example (examples):
/* scroll-animations-1: each child fades in as it enters the scrollport */
@keyframes reveal {
from {
opacity: 0;
}
}
.scroller > * {
animation: reveal linear both;
animation-timeline: view();
animation-range: entry;
}Durations become proportions of a finite range: "Unlike time-driven timelines, scroll-driven timelines are finite, thus scroll-driven animations are always attached to a finite attachment range […] If the specified duration is auto, then the remaining range is divided by its iteration count" (§ Finite Timeline Calculations).
When a scroll timeline is sampled
Scroll-driven effects can move layout, and layout can move scroll, so the spec pins the sample point (§ HTML Processing Model: Event loop):
"To avoid such layout cycles, animations with a scroll progress timeline update their current time once during step 7.10 of the HTML Processing Model event loop, as step 1 of update animations and send events."
Timelines created during style and layout are stale and get one extra style/layout round in the same frame, to avoid "an undesirable initial "flash"". The compositor may run ahead: "If a user agent normally composites frames where scrolling has occurred but the consequences of scrolling have not been fully propagated in layout or script […] the user agent may likewise choose not to sample scroll-driven animations for that composited frame" (same).
How it works: View Transitions
The lifecycle
document.startViewTransition(updateCallback) returns a ViewTransition and runs (§ View Transition Lifecycle):
- "Current state captured as the "old" state."
- "Rendering paused."
- the update callback runs and changes the DOM;
updateCallbackDonefulfils; - "Current state captured as the "new" state."
- "Transition pseudo-elements created."
- "Rendering unpaused, revealing the transition pseudo-elements.";
readyfulfils; - "Pseudo-elements animate until finished."; they are removed;
finishedfulfils.
Normatively, setup view transition flushes pending update callbacks, captures the old state, sets the document's rendering suppression for view transitions flag, schedules the update callback, and on its completion clears the flag and captures the new state (§ Setup view transition). A second startViewTransition while one is active skips the first with an AbortError — there is no retargeting between view transitions (startViewTransition() steps).
Capturing the old state: a raster snapshot
Capture the old state walks every connected element in paint order, collects those with a view-transition-name (failing the whole transition on a duplicate name), and for each records (§ Capture the old state):
- its old image — "the result of capturing the image of element";
- its old width/height (border box) and old transform — "a transform-function that would map element's border box from the snapshot containing block origin to its current visual position";
- a few computed values (
writing-mode,direction,text-orientation,mix-blend-mode,backdrop-filter,color-scheme).
Capture the image renders the element and its descendants onto a transparent canvas and returns the ink-overflow area as an image whose natural size is the border box (§ Capture the image). The ::view-transition-old() pseudo-element is "an empty named view transition pseudo-element that represents a visual snapshot of the "old" state as a replaced element" (§ ::view-transition-old()), styled with object-* like an img. The old element may be gone from the DOM by the time it paints — the snapshot is a bitmap plus a recorded rect, not a reference to the node.
Capturing the new state: a live capture
Capture the new state records only the new element reference for each name (§ Capture the new state). Its image is re-captured every frame: update pseudo-element styles sets the ::view-transition-new() replaced content "to the result of capturing the image of capturedElement's new element" and copies its current geometry into the group's styles (§ Update pseudo-element styles). So "old" is frozen and "new" is live. The original elements do not paint in place while the transition animates: "the boxes generated by any element in that Document with captured in a view transition […] are not painted (as if they had opacity: 0) and do not respond to hit-testing" (§ View Transition Painting Order).
The pseudo-element tree
::view-transition
├─ ::view-transition-group(name)
│ └─ ::view-transition-image-pair(name)
│ ├─ ::view-transition-old(name)
│ └─ ::view-transition-new(name)
└─ …other groups…(§ View Transition Pseudo-elements). The root has the name root via the UA style sheet. Either image is absent when there is no old or new state — that absence is how entry-only and exit-only names are expressed. The tree paints in a new view transition layer "after all other content of the document (including any content rendered in the top layer)" (§ View Transition Painting Order).
The default animation is generated CSS
Setup transition pseudo-elements writes rules into a per-document dynamic view transition style sheet (§ Setup transition pseudo-elements):
- old only (exit):
::view-transition-old(name) { animation-name: -ua-view-transition-fade-out; }; - new only (entry):
::view-transition-new(name) { animation-name: -ua-view-transition-fade-in; }; - both: a group keyframes rule with only a
fromframe —
/* css-view-transitions-1, setup transition pseudo-elements (variables substituted at runtime) */
@keyframes -ua-view-transition-group-anim-NAME {
from {
transform: OLD-TRANSFORM;
width: OLD-WIDTH;
height: OLD-HEIGHT;
backdrop-filter: OLD-BACKDROP-FILTER;
}
}— so the implicit to frame is the group's current style, which update pseudo-element styles keeps equal to the new element's live geometry; plus a cross-fade of old and new with mix-blend-mode: plus-lighter. The UA sheet sets animation-duration: 0.25s on groups and inherits timing down the tree (§ User Agent Stylesheet). If the new element moves mid-transition a new keyframe is generated, and the spec accepts the jump: "a change in incoming element's size or position will cause a new keyframe to be generated. This can cause a visual jump. We could retarget smoothly but don't have a use-case to justify the complexity" (§ Handle transition frame). The transition ends when no animation on the pseudo-tree is running or paused (same).
Level 2: cross-document, classes, types, scoped
Level 2 adds "Cross-document view transitions, including the @view-transition rule", selective transitions by type, view-transition-class, nested groups and scoped (element-rooted) transitions (Level 2 updates).
- Cross-document: a same-origin, user-initiated navigation transitions when both documents opt in with
@view-transition { navigation: auto; }(@view-transition); the old document's last frame stays up while the new one is render-blocked — "overusing the render-blocking mechanism could make it so that the old state remains frozen for a long time" (§ Waiting for the new state to stabilize). view-transition-class: shared styling for many names,::view-transition-group(*.any-box); it "doesn't mark an element for capturing" (view-transition-class).- Types:
startViewTransition({ update, types }), a mutableViewTransitionTypeSet, and:active-view-transition-type(…)on the root to select per-type styles (API, types, pseudo-class). - Scoped: "individual elements can host their own scoped view transitions. This enables multiple view transitions to run on a page at the same time", under automatic layout containment (§ Scoped View Transitions).
view-transition-name: autogenerates names (fromidwhen present) (§ Determining view-transition-name automatically).
// same-document view transition with a type
const vt = document.startViewTransition({
update: () => list.removeChild(item), // DOM changes at once
types: ['delete'],
});
await vt.finished;li {
view-transition-name: auto;
view-transition-class: row;
}
:root:active-view-transition-type(delete)::view-transition-old(
*.row
):only-child {
animation: 200ms ease-in both shrink-out; /* the removed row's snapshot */
}Analysis
Where animation state lives
Scroll-driven: in the scroll offset; the timeline holds no state of its own beyond its source, axis and computed ranges, and the attached Animation is ordinary (§ Scroll Progress Timelines). View Transitions: in the ViewTransition — the named elements map, keyed by view-transition-name, of captured elements holding the old image, old geometry and the new element (§ Capture the old state), plus the pseudo-element tree and the CSS Animations on it. The map is keyed by name, a stable identity chosen by the author, not by DOM node.
Declaring an animation
Scroll-driven: declarative and explicit (an @keyframes plus animation-timeline: view()), or imperative via new ScrollTimeline in animate(). View Transitions: an imperative trigger (startViewTransition(update)) or a declarative one for navigations (@view-transition), with a default animation that is implicit — every named element's geometry change and cross-fade animates without being described (§ Setup transition pseudo-elements) — and customised declaratively via ::view-transition-* selectors.
Time and the clock
Scroll-driven: no time. The timeline is a progress-based timeline whose value is a percentage of the scroll range; durations are proportions; the scroll position — the user, or the compositor's async scroll — is the clock (Web Animations 2, § Finite Timeline Calculations). The UA samples once per frame at a defined step and may skip sampling on compositor-only frames (§ HTML Processing Model: Event loop). View Transitions: the pseudo-elements' animations run on the document timeline, with a UA default of 0.25 s (§ User Agent Stylesheet); between old capture and new capture, rendering is suppressed, so the page's own clock-driven painting pauses.
Interruption and retargeting
Scroll-driven: no interruption — reversing the scroll reverses progress, a direct consequence of the stateless timing model. View Transitions: none. A new startViewTransition skips the active one (steps); a moving new element regenerates keyframes and may jump, and the spec declines smooth retargeting for lack of a use case (§ Handle transition frame). Velocity is never carried.
Curves and springs
Both reuse CSS easing. For scroll-driven animations easing applies to scroll progress (linear is the usual choice so the effect tracks the finger). View Transitions use animation-timing-function on the pseudo-elements; springs only as sampled linear() (CSS Easing).
Layout animation
View Transitions are UA-implemented FLIP. First is captured from the previous rendered frame — the old image and the old border-box geometry and transform of every named element (§ Capture the old state); Last is the new element's live geometry after the DOM update and layout, refreshed every frame (§ Update pseudo-element styles); the animation interpolates the group's transform, width and height from the old values to the new ones (§ Setup transition pseudo-elements). Phase: capture happens in the rendering update (paint output for the image, layout output for the rect); the group's width/height animation re-lays-out the pseudo-elements each frame, while the image transforms and cross-fade are compositable. So it needs the previous frame's geometry and pixels, but it obtains them in the UA, not in user code — unlike FLIP. Scroll-driven animations animate whatever the keyframes say, like CSS Animations; their timeline needs the current layout's scroll range and view ranges, recomputed in the frame's style/layout step (§ HTML Processing Model: Event loop).
Enter and exit
View Transitions are the platform's answer to exit animation of removed content. An element with a view-transition-name in the old state and none in the new produces a group with only ::view-transition-old(), which keeps painting the raster snapshot — with the element's recorded geometry — while the live DOM has already changed, and fades out by default (§ Setup transition pseudo-elements, § ::view-transition-old()). The element itself can be gone: the snapshot is a replaced-element bitmap, so it neither lays out in the page nor receives events (the view transition tree "is not exposed to the accessibility tree", § View Transition Pseudo-elements). Entry is the symmetric case, a ::view-transition-new() alone, fading in. The cost is that the old content is frozen pixels: it cannot reflow, animate internally or respond while it exits. Scroll-driven animations have no enter/exit concept beyond the entry/exit view ranges, which describe scroll geometry, not tree membership.
Scheduling, reduced motion and testing
Scroll-driven: samples only when the scroll position or ranges change, and are designed to need no script per sample (§ Relationship to asynchronous scrolling). View Transitions: frames run only while a pseudo-element animation runs; the transition is torn down when none remain (§ Handle transition frame); skipTransition() skips the animation but still runs the update. Neither spec mentions prefers-reduced-motion — a search of both sources finds no reference — so reduced motion is the author's @media (prefers-reduced-motion: reduce) rule, e.g. disabling the ::view-transition-* animations, which still leaves the instant DOM change because a transition is an enhancement (§ Transitions as an enhancement). Testing: scroll-driven state is a function of scroll offset, so a test scrolls to a position and reads styles; view transitions are tested through their promises (updateCallbackDone, ready, finished) and, since the pseudo-element animations are Web Animations, by document.getAnimations() and seeking.
Lessons for sparkles:ui
- UI-Q10 answer, platform version: keep painting a removed element from a retained snapshot keyed by a stable identity, captured before the frame that removes it. In
sparkles:ui, the host can do this without a bitmap: last frame's display list (or retained draw ops) for the removed identity's subtree, plus its last committed rect from the store, is the "old image". It costs no rebuild of the removed component and keeps components pure. - The snapshot's limits are inherent: frozen content, no hit testing, no internal animation. A "closing state" in the store (the CSS
allow-discretemodel) is the alternative when the exiting element must stay interactive or keep animating internally. - UI-Q9 answer, platform version: layout animation via old-rect → new-rect needs last frame's committed geometry, read by the host after layout, not by components. View Transitions show the UA can own FLIP entirely;
sparkles:ui's host is in the same position, having both rects without a forced layout. - Pairing by name, not node, maps onto keyed identity: an element moved between parents in the tree keeps its key, so the host can pair old and new by identity as View Transitions pair by
view-transition-name. - Scroll timelines show that progress-based timelines plug into a stateless timing model for free; in
sparkles:uithe store's scroll offset (already presentation state) can be such a timeline, sampled after layout so the range is current — the one-sample-per-frame rule avoids the layout cycle the spec describes.
Strengths
- Scroll-driven: scroll-linked effects with no per-scroll script, compatible with compositor scrolling; reversible by construction.
- View Transitions: exit and shared-element animations without keeping old DOM alive; the DOM changes atomically and accessibly.
- View Transitions reuse CSS Animations and Web Animations entirely; the default is generated CSS that authors override.
- Name-based pairing works across containers and, in Level 2, across documents.
Weaknesses
- View Transitions' old state is frozen pixels; text reflow and internal animation of exiting content are impossible.
- No retargeting: a new view transition aborts the running one; moving targets jump.
- Global view transitions suppress rendering while the update callback runs; slow updates freeze the page.
- Duplicate names abort the transition; every participant needs a unique name (Level 2's
automitigates). - Neither spec handles reduced motion; it is entirely author responsibility.
- Scroll-driven sampling can lag async scroll on compositor-only frames.
Key design decisions and trade-offs
| Decision | Rationale | Trade-off |
|---|---|---|
| Scroll position as a progress-based timeline (percent, no time) | Reuses keyframe effects; stateless; compositor-sampleable | Durations become proportions; delays and iterations need reinterpretation |
| Sample scroll timelines once per frame at a fixed step | Breaks the scroll ↔ layout cycle | A stale timeline needs an extra style/layout pass; async scroll may outrun it |
| Old state as a raster snapshot, new state as a live capture | DOM switches instantly; old content needs no DOM to exit | Old content is frozen; memory for snapshots; size limits fail the transition |
Pairing by view-transition-name | Shared-element transitions across containers and documents | Names must be unique per frame or the whole transition aborts |
Default animation is generated from-only keyframes | to tracks the live new geometry; authors override with plain CSS | Changing new geometry regenerates keyframes and can jump |
| Transition as enhancement; update always runs | Failure never blocks state change | No coordination of concurrent updates; left to frameworks |
| Pseudo-tree in a top layer above all content (global VTs) | Avoids clipping by old/new containers | Ignores page clipping/z-order; Level 2 scoped VTs needed for in-flow effects |
Sources
- Scroll-driven Animations, editor's draft, rendered, TR, source (
scroll-animations-1/Overview.bsat9c7ee53). - CSS View Transitions Module Level 1, rendered, TR, source.
- CSS View Transitions Module Level 2, rendered, TR, source.
- Web Animations Level 2, progress-based timelines and
AnimationTimeline. - CSS Animations Level 2,
animation-timeline. - MDN, View Transition API and CSS scroll-driven animations (secondary).