大网数据广告活动
Web 标准与前端开发

ViewTransitionTypeSet

· 52CE 我爱测

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.

View Transition API

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 ViewTransition.types property.

The property and method links below link to the JavaScript Set object documentation.

Instance properties

  • Set.prototype.size
    • : Returns the number of values in the set.

Instance methods

  • Set.prototype.add
    • : Inserts the specified value into this set, if it is not already present.
  • Set.prototype.clear()
    • : Removes all values form the set.
  • Set.prototype.delete()
    • : Removes the specified value from this set, if it is in the set.
  • Set.prototype.entries()
    • : Returns a new iterator object that contains an array of [value, value] for each element in the set, in insertion order.
  • Set.prototype.forEach()
    • : Calls a callback function once for each value present in the set, in insertion order.
  • Set.prototype.has()
    • : Returns a boolean indicating whether the specified value exists in the set.
  • Set.prototype.keys()
    • : An alias for Set.prototype.values().
  • Set.prototype.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

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。