Skip to content
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

[css-animations] Support iterationCount field in animationIteration event #3620

Open
hunboy opened this issue Feb 7, 2019 · 3 comments
Open
Labels
Agenda+ Later Lower-priority items that are flagged for CSSWG discussion css-animations-2

Comments

@hunboy
Copy link

hunboy commented Feb 7, 2019

Currently the iterationCount variable (field) is missing in the animationiteration event. In some cases - especially when the iteration-count is significant, we might know the exact value: which iteration happens currently.

Simple sample here: https://jsfiddle.net/utasir/4wn52fdo/
In this testcase I had to use a "global" variable to count the iteration, but this sounds as a hack.

Here are the fields, what we have currently in the event object:
iteration

So, my suggestion is: adding a new field which shows the current iteration number.

@birtles
Copy link
Contributor

birtles commented Feb 11, 2019

This seems like a very reasonable suggestion with a clear use case (and happens to be easy to implement).

For the name I'm afraid that iterationCount might sound too similar to animation-iteration-count and could be confused as representing the total number of iterations. Perhaps currentIteration? elapsedIterations?

@fantasai fantasai added the Agenda+ Later Lower-priority items that are flagged for CSSWG discussion label Jun 2, 2023
@astearns astearns added this to Unslotted in TPAC 2023 agenda Sep 7, 2023
@bramus
Copy link
Contributor

bramus commented Sep 11, 2023

+1 on adding such a property.

With the animation now being passed into the event (see resolution), I think it’s best to add this to the Animation object instead of the event so that it can be used in more than just the animationIteration event.

As for naming this: currentIteration as a name takes my preference, as an author most likely wants to know the current iteration count instead of previous (elapsed) count. Also fine with currentIterationCount, which is even more expressive of what it is about.

@birtles
Copy link
Contributor

birtles commented Sep 12, 2023

I don't think this should be added to the Animation object. It's a property of an animation effect (assuming there is one) and I don't think we want to lift all the timing properties from the root animation effect to the Animation.

Also, the value in the event should a static snapshot of the iteration count at the time the event was triggered, not the current live value.

If the authors wants the live value they can fetch it in the same way they fetch the live progress, i.e. animation.effect?.getComputedTiming().currentIteration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agenda+ Later Lower-priority items that are flagged for CSSWG discussion css-animations-2
Projects
Development

No branches or pull requests

5 participants