Element: activeViewTransition property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

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 having to worry about saving a reference for easy access later on.

An element-scoped ViewTransition can also be accessed via the return value of Element.startViewTransition().

Value

A ViewTransition or null if the element has no active view transition.

Examples

Basic usage

js
const myElement = document.querySelector(".my-element");

// ...

function handleVT() {
  const vt = myElement.startViewTransition(() => {
    updateDOMSomehow();
  });
}

// Returns reference to vt, above, provided transition is still ongoing
myElement.activeViewTransition;

Specifications

Specification
CSS View Transitions Module Level 2
# dom-element-activeviewtransition

Browser compatibility

See also