web api instance property
Element: activeViewTransition property
Limited availability
The activeViewTransition read-only property of the Element interface returns a ViewTransition instance representing the view transition currently active on an element. It provides a consistent way to access an active element-scoped view transition without needing to save a reference to it for later.
An element-scoped ViewTransition can also be accessed via the return value of startViewTransition().
Value
A ViewTransition or null if the element has no active view transition.
Examples
Basic usage
This snippet shows how to use activeViewTransition to retrieve a reference to an ongoing view transition.
const myElement = document.querySelector(".my-element");
// ...
function handleVT() {
const vt = myElement.startViewTransition(() => {
updateDOMSomehow();
});
}
// Returns a reference to vt if the transition is still ongoing
myElement.activeViewTransition;
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.