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> |
浏览器兼容性
Loading…