v142 · javascript
activeViewTransition property on document
View Transitions API allows developers to start visual transitions between different states. The primary SPA entry point to this is `startViewTransition()` which returns a transition object. This object contains several promises and functionality to track the transition progress, as well as allow manipulations such as skipping the transition or modifying its
concepts
-
Active VT
Trigger a real view transition and watch
document.activeViewTransitionflip fromnullto a live object and back. Double-click "swap fast" — the guard skips the second call. -
Concurrent Navigation Guard
The real reason the property landed — SPA routers fire navigations faster than transitions can finish. A miniature router uses
activeViewTransitionto drop racing route clicks instead of letting them cancel the in-flight transition. -
External Skip & Observe
An external module (back-button handler, reduced-motion watcher, telemetry layer) reaches into the live transition via
document.activeViewTransitiontoskipTransition()mid-flight, or attach observers toready,finished, andupdateCallbackDone— without holding the original caller's handle. -
Transition Performance Lab
Click a tile to start a view transition, then watch
performance.measure()and a PerformanceObserver capture the frame budget, paint entries, and duration. A "stress test" fires 5 transitions in rapid succession — the concurrent guard skips racing calls and the skipped count appears in the log. -
Element-scoped activeViewTransition
CSS View Transitions Level 2 splits the API into two axes:
document.startViewTransition()setsdocument.activeViewTransition, whileelement.startViewTransition()setselement.activeViewTransitionindependently. Click each panel to start a scoped transition and watch which property lights up in the side-by-side readout. -
Navigation Queue Strategies
SPA routers face a race: users click routes faster than view transitions can finish. Two strategies using
document.activeViewTransition: drop (ignore racing clicks) and queue-latest (let the current transition finish, then run the most-recent pending navigation). Spam the route buttons and watch the counters.
why it shipped
View Transitions API allows developers to start visual transitions between different states. The primary SPA entry point to this is `startViewTransition()` which returns a transition object. This object contains several promises and functionality to track the transition progress, as well as allow manipulations such as skipping the transition or modifying its