Animation() constructor of the Web 动画 API returns a new 动画 对象实例。

句法

var animation = new Animation([effect][, timeline]);
					

参数

effect 可选
The target effect, as an object based on the AnimationEffectReadOnly interface, to assign to the animation. Although in the future other effects such as SequenceEffect s or GroupEffect s might be possible, the only kind of effect currently available is KeyframeEffect . This can be null (which is the default) to indicate that there should be no effect applied.
timeline 可选
Specifies the timeline with which to associate the animation, as an object of a type based on the AnimationTimeline interface. Currently the only timeline type available is DocumentTimeline , but in the future there my be timelines associated with gestures or scrolling, for example. The default value is Document.timeline , but this can be set to null 还。

范例

Follow the White Rabbit example Animation() constructor is used to create an 动画 rabbitDownKeyframes using the document's timeline :

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

规范

规范 状态 注释
Web 动画
The definition of 'Animation()' in that specification.
工作草案 编者草案。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Animation() 构造函数 Chrome 61 Edge ≤79 Firefox 48 IE 不支持 No Opera 48 Safari 不支持 No WebView Android 61 Chrome Android 61 Firefox Android 48 Opera Android 45 Safari iOS 不支持 No Samsung Internet Android 8.0

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改: