lynx   »   [go: up one dir, main page]

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Animation.Animation()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2020年3月⁩.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

Animation 构造函数返回一个新的 Animation 对象实例。

语法

js
var animation = new Animation(effect, timeline);

参数

effect 可选

KeyframeEffect对象分配给动画。(在将来,其他类型的效果,如 SequenceEffects 或 GroupEffects 是可能被实现的,但现在,唯一的效果是 KeyframeEffect。)

timeline 可选

指定与动画关联的时间轴。(目前唯一可用的时间轴类型是DocumentTimeline,但在将来我会有与手势或滚动相关联的时间轴。)默认为Document.timeline。这也可以设置为 null。

例子

White Rabbit示例中,Animation 构造函数用于使用文档时间轴为兔子创建关键帧动画:

js
var rabbitDownAnimation = new Animation(rabbitDownKeyframes, document.timeline);

规范

Specification
Web Animations
# dom-animation-animation

浏览器兼容性

参见

Лучший частный хостинг