web api interface
ViewTransitionTypeSet
The ViewTransitionTypeSet interface of the View Transition API is a set-like object representing the types of an active view transition. This enables the types to be queried or modified on-the-fly during a transition.
The ViewTransitionTypeSet object can be accessed via the types property.
The property and method links below link to the JavaScript Set object documentation.
Instance properties
size- : Returns the number of values in the set.
Instance methods
add- : Inserts the specified value into this set, if it is not already present.
clear()- : Removes all values form the set.
delete()- : Removes the specified value from this set, if it is in the set.
entries()- : Returns a new iterator object that contains an array of
[value, value]for each element in the set, in insertion order.
- : Returns a new iterator object that contains an array of
forEach()- : Calls a callback function once for each value present in the set, in insertion order.
has()- : Returns a boolean indicating whether the specified value exists in the set.
keys()- : An alias for
values().
- : An alias for
values()- : Returns a new iterator object that yields the values for each element in the set, in insertion order.
Set.prototype[Symbol.iterator]()- : Returns a new iterator object that yields the values for each element in the set, in insertion order.
Examples
// Start a view transition
const vt = document.startViewTransition({
update: updateTheDOMSomehow,
types: ["slideLeft", "fadeOut", "flipVertical"],
});
// Add another type
vt.types.add("flipHorizontal");
// Delete a type
vt.types.delete("flipVertical");
// Return the number of types in the set
console.log(vt.types.size);
// Log each type to the console
vt.types.forEach((type) => console.log(type));
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.