Re: [css-animations] animation-iteration-count: infinite and animation-duration: 0s

On Sep 4, 2014, at 4:18 PM, Brian Birtles <bbirtles@mozilla.com> wrote:

> On 2014/09/05 4:36, Sylvain Galineau wrote:
>> 
>> On Sep 3, 2014, at 7:27 PM, Brian Birtles <bbirtles@mozilla.com> wrote:
>> 
>>> Hi,
>>> 
>>> While we're tying up loose ends in CSS animations, what is the behavior of the following?
>>> 
>>>  animation-duration: 0s;
>>>  animation-iteration-count: infinite;
>>>  animation-fill-mode: both;
>>> 
>>> The problem arises because when we come to calculate the active duration of the animation we get:
>>> 
>>>  active duration = 0 * infinity = indeterminate form
>>> 
>>> In Web Animations we came across this situation and considered some possibilities:
>>> 
>>>  a) let active duration = 0 -> final key frame value is shown, start/end events are dispatched
>>> 
>>>  b) let active duration = infinity -> initial key frame value is shown, start event only is dispatched
>>> 
>>>  c) it's invalid -> nothing is shown, no events are dispatched
>>> 
>>> Currently, the spec says (a)[1] but when we discussed this recently we decided (b) is probably preferable.[2]
>>> 
>>> We liked (c) too but it complicated the model and the API since it involves more checks for this particular edge case.
>>> 
>>> What do you think?
>> 
>> (a) seems hard to explain, imo.
> 
> It's basically treating the animation as if it finished instantaneously hence it just keeps filling with the final value.

Right, I think you can only explain it as 'duration takes precedence over iteration count', otherwise I think it's weird for something on infinite repeat to end and show the forward fill.

> 
>> (b) sounds reasonable, though I assume the initial keyframe is only visible because the iteration count is infinite?
> 
> Right, in this approach the animation is infinitely long so it never progresses past the first frame.
> 
>> (c) Yeah, no sure why this needs to be invalid.
> 
> Because you're effectively specifying an animation of undefined length. Is it zero? Is it infinity? Actually, mathematically, it's neither. It's NaN.

Well, it's NaN for Javascript :) Anything times 0 should be 0 and oh noes now a) makes sense.

> The correct thing is to not run the animation but that might not be the most useful thing.
> 
> I'm ok with (b) if everyone else agrees but if anyone wants to argue for (c) I'd be sympathetic to that.
> 
> Best regards,
> 
> Brian

Received on Thursday, 4 September 2014 23:45:29 UTC