AnimationEvent()

Experimental: 这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

The AnimationEvent() constructor returns a newly created AnimationEvent, representing an event in relation with an animation.

语法

animationEvent = new AnimationEvent(type, {animationName: aPropertyName,
                                           elapsedTime  : aFloat,
                                           pseudoElement: aPseudoElementName});

参数

Also inherits properties from its parent Event.

AnimationEvent.animationName 只读

A string containing the value of the animation-name that generated the animation.

AnimationEvent.elapsedTime (en-US) 只读

A float giving the amount of time the animation has been running, in seconds, when this event fired, excluding any time the animation was paused. For an animationstart event, elapsedTime is 0.0 unless there was a negative value for animation-delay, in which case the event will be fired with elapsedTime containing (-1 * delay).

AnimationEvent.pseudoElement (en-US) 只读

A string, starting with '::', containing the name of the pseudo-element the animation runs on. If the animation doesn't run on a pseudo-element but on the element, an empty string: ''.

标准

Specification
CSS Animations Level 1
# dom-animationevent-animationevent

浏览器兼容性

BCD tables only load in the browser

参考