Element: activeViewTransition property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("View Transition API")}}{{SeeCompatTable}}
The **activeViewTransition** read-only property of the {{domxref("Element")}} interface returns a {{domxref("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 {{domxref("ViewTransition")}} can also be accessed via the return value of {{domxref("Element.startViewTransition()")}}.
Value
A {{domxref("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
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{domxref("Element.startViewTransition()")}}
- {{domxref("Document.activeViewTransition")}}
- Using element-scoped view transitions
- View Transition API
- {{domxref("ViewTransition")}}