-
Notifications
You must be signed in to change notification settings - Fork 711
[web-animations-2] Add Animation.started
and Animation.playing
promises
#5871
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
Comments
Thanks for filing this issue. I wonder if you could elaborate on the use cases for this? I'm not sure that Promises are the right fit for this use case. The Writing Promise-Using Specifications document gives some guidance about when to use Promises vs events. In this case a start event can happen many times because:
So it would seem like events would be a better fit for this. Regarding the third point above, it might also make sense to specify that such events only apply to the delay defined on the root effect, but then I believe authors will also want events on child effects and I don't know how we can fix that without introducing performance issues. I believe we've seen similar proposals before so it might be worth searching for them and seeing what the concerns were then. |
Animation.started
and Animation.playing
promisesAnimation.started
and Animation.playing
promises
Related Proposals
Motivation & Use CasesOften, an author needs to synchronize arbitrary code with a web animation. For example, during a few key points in an animation lifecycle, one may need to manipulate the DOM, or initiate network requests, or conditionally trigger other animations, among other things. These key lifecycle points are:
There is precedent for the usefulness of such triggers in the existence of:
Authors can already be informed when an animation is finished (case #1 above) via the Promise vs EventThe unhandled cases 2, 3, and 4 from above can be separated into two groups:
|
Animation.started
and Animation.playing
promisesAnimation.started
and Animation.playing
promises
Animation.started
and Animation.playing
promisesAnimation.started
and Animation.playing
promises
Thank you! That looks right.
Thank you. I was hoping there might be more specific use cases but the precedent of CSS animation events is compelling enough that I think this makes sense.
The Initially the expectation was that user agents might take different amounts of time to setup animations but in practice all user agents resolve the promise on the next animation frame unless the animation is already playing or unless it is associated with an inactive timeline. As for use cases, it lets you know when it is safe to read the I'm still not clear on the use cases for the As I understand it, the examples for "More general state transitions" in that document refer to async operations that differ from this case. Also it seems like the warnings about over-using Promises apply to this case, at least as I understand it.
Thanks, that's great. (I've moved this discussion to web-animations-2 in keeping with the discussion there.) Yes, it does sound like we could resolve the performance issues I had in mind.
That all seems reasonable.
I wonder if that would be necessary if we make the target of the event the
I'm personally still unclear about |
EDIT: I cleaned up a few things since yesterday Thanks for taking the time to explain all that! I'll create a separate proposal for
Hmm. I interpreted this category as explicitly referring to methods that "return a promise", not properties, but perhaps that's a distinction without a difference. Anyway, I think I found a better way to articulate what I want. Better Explanation of
|
Thank you for taking the time to explain this use case. I really appreciate it. I've read it through and I think I understand the scenario. Firstly, I think you'd want to define that such a promise is replaced when That said, I'm still not sure that this pattern is common enough to warrant adding to the platform. Like you said, you could accomplish your particular case by wrapping the For the timeline UI case, I think it might be better to pursue a more generic animation mutation observer API. That's what Firefox uses internally for its animation DevTools and I'm told Chrome has something similar so if we could standardize the behavior of this interface we could potentially expose it to Web content. It's more work to specify, but likely to be useful to more applications. Of course, if you can convince other parties that the |
Thanks for your response. What are your thoughts on my "Alternative" section on my last comment? i.e. what is the rationale for having the |
The |
Right. I guess I'm still struggling to understand how a resolved promise can represent both the completion of an asynchronous operation and also represent no asynchronous operation having been run at all. Perhaps I should have said: |
Problem
Animation
to be played at a later time, there's no way to know when it's actually playing.delay
, there's no way to know when the animation effect actually starts.Proposal
Introduce two new promises on
Animation
:Animation.playing
: returns aPromise
which resolves once the animation has started playing.Animation.started
: returns aPromise
which resolves once thedelay
period is over and the effect has startedAlternatives
Animation.played
instead ofAnimation.playing
for consistency in tense withAnimation.finished
Animation.effectStarted
instead ofAnimation.started
for clarificationThe text was updated successfully, but these errors were encountered: