Skip to content

[web-animations-2] Animate - Add more event handlers #6166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
glenn2223 opened this issue Mar 31, 2021 · 3 comments
Open

[web-animations-2] Animate - Add more event handlers #6166

glenn2223 opened this issue Mar 31, 2021 · 3 comments
Labels
web-animations-2 Current Work

Comments

@glenn2223
Copy link

glenn2223 commented Mar 31, 2021

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)

@birtles birtles added the web-animations-2 Current Work label Mar 31, 2021
@birtles birtles changed the title [web-animations-1] Animate - Add more event handlers [web-animations-2] Animate - Add more event handlers Mar 31, 2021
@birtles
Copy link
Contributor

birtles commented Mar 31, 2021

Moving to web-animations-2 because we're not going to add any major new features to level 1.

There are a few similar issues where I've pointed out some of the difficulties in doing this but it's clear we need to do something in this space eventually. I'd rather see group effects fleshed out first, however, since that will introduce a lot of constraints on the solution.

@glenn2223
Copy link
Author

Thanks for the reply.

There are a few similar issues where I've pointed out some of the difficulties...

Ahh, found them (#5871, #4461 & #4324). Sorry, I must have had a typo when I searched the first time 🤦‍♂️

@mattgperry
Copy link

To add to this, I noticed iteration events are missing from this spec but present in CSS animations. It'd be great to add onIteration or similar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-animations-2 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants