close

Element: activeViewTransition property

Limited availability

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

Want more support for this feature? Tell us why.

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().

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.

js
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

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

Browser compatibility

See also