[web-animations-2] Animate - Add more event handlers
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Animation interface in the Web Animations specification and review the linked CSSWG draft and JSFiddle proposals. Compare the requested onstart, onAnimationStart, onAnimationFinish, and onKeyFrame handlers with the existing AnimationPlayState behavior. Done means the event-handler design and delayed-versus-running behavior are resolved in the specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, javascript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100