Animation.Animation()
Baseline 2022
Newly available
Since September 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
语法
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 |
浏览器兼容性
BCD tables only load in the browser