Description
Ref: https://drafts.csswg.org/web-animations-1/#the-animation-interface
Could these proposed event handlers be added to the Animation interface?
onstart
Example/proposal: https://jsfiddle.net/glenn2223/gj7heoLv/
Details
The event handler for each time the animation starts
Reason
In case someone wants to change the state it starts, as they can currently do when it finishes.
Currently, as per the example, setting any state before the calling play()
causes issues when there is a delay
or endDelay
onAnimationStart
- possible handler. Maybe a higher preference to the onKeyFrame
handler?
Details
This would fire on (or just before) the first frame being initiated (or the implied first frame in the case of implicit to/from keyframes)
Reason
To fire an event the second that the animation actually starts (after delays)
onAnimationFinish
- possible handler. Maybe a higher preference to the onKeyFrame
handler?
Details
This would fire on (or just after) the last frame being initiated (or the implied last frame in the case of implicit to/from keyframes)
Reason
To fire an event the second that the animation actually ends (before delays)
onKeyFrame (index: number)
Proposal: https://jsfiddle.net/glenn2223/uwg589Lx/
Details
This would fire on each keyframe that is hit, passing the index of the keyframe
Reason
You can fire events at certain stages of the animation process as per the details in the proposal link just above.
Also, is there a way to detect if it's actually running or just delayed? I saw the AnimationPlayState
enumeration but that doesn't;t have a startDelay
or endDelay
state.
I only ask because if it's delayed I'd rather call cancel()
but if it's running I'd rather call finish()
(Should I open a new issue)