Re: [web-animations] please, clarify consequences of changing KeyframeEffect.spacing attribute

Hi Aleksei,

Thanks for your question.

On 2014/12/03 19:38, Aleksei Semenov wrote:
> According to the specification,
> http://w3c.github.io/web-animations/#dom-keyframeeffect-getframes
> spacing keyframes, i.e. attributes computedOffset are calculated in
> method KeyframeEffect.getFrames().

Yes, but this procedure is also run even if getFrames is not called. It 
is performed before calculating values for a keyframe animation effect:

"Before calculating animation values from a keyframe animation effect, 
an absolute value must be computed for the keyframe offset of each 
keyframe with a null offset."[1]

> The calculation algorithm depends on KeyframeEffect.spacing value.
> So if KeyframeEffect.spacing is changed, next call to
> KeyframeEffect.getFrames() returns different result.

Correct.

> For example,
>
> var keyframes = [{top: '10px'}, {top: '30px', width: '40px'}, {top:
> '100px}, {width: '90px'}];
> var effect = new KeyframeEffect(keyframes, 'paced(top)');
> var pacedTopFrames = effect.getFrames();
> effect.spacing = 'distribute';
> var distributeFrames = effect.getFrames();
> effect.spacing = 'paced(width)';
> var pacedWidthFrames = effect.getFrames();
> // pacedTopFrames, distributeFrames, pacedWidthFrames have different
> computedOffset values, right?

Correct.

> Could you clarify the side effects of such changes?
> For example, what happens with currently running animation?

I don't understand why this is any different to other changes to timing 
or animation parameters?

For example, if you call setFrames() the animation will update to use 
the new keyframes. Likewise, if you change the spacing property the 
animation will update to use the new keyframe offsets.

Best regards,

Brian

[1] http://w3c.github.io/web-animations/#spacing-keyframes

Received on Tuesday, 9 December 2014 01:52:17 UTC