Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
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 Element.startViewTransition().
A ViewTransition or null if the element has no active view transition.
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;