Re: [csswg-drafts] [web-animations-1] Replace AnimationEffectTiming(ReadOnly) with setTiming() ?

I had a go at implementing this in Firefox just to see how it feels. The modified IDL I used is:

```webidl
dictionary EffectTiming {
  double                              delay = 0.0;
  double                              endDelay = 0.0;
  FillMode                            fill = "auto";
  double                              iterationStart = 0.0;
  unrestricted double                 iterations = 1.0;
  (unrestricted double or DOMString)  duration = "auto";
  PlaybackDirection                   direction = "normal";
  DOMString                           easing = "linear";
};

dictionary PartialEffectTiming {
  double                              delay;
  double                              endDelay;
  FillMode                            fill;
  double                              iterationStart;
  unrestricted double                 iterations;
  (unrestricted double or DOMString)  duration;
  PlaybackDirection                   direction;
  DOMString                           easing;
};

dictionary ComputedEffectTiming : EffectTiming {
  unrestricted double   computedDuration = 0.0;
  FillMode              computedFillMode = "none";
  unrestricted double   endTime = 0.0;
  unrestricted double   activeDuration = 0.0;
  double?               localTime = null;
  double?               progress = null;
  unrestricted double?  currentIteration = null;
};

interface AnimationEffectReadOnly {
  ComputedEffectTiming getTiming();
  void setTiming(optional EffectTiming timing);
  void updateTiming(optional PartialEffectTiming timing);
};
```

As you can see I took the liberty of renaming some of the dictionaries at the same time. (Now that we no longer have `AnimationEffectTiming(ReadOnly)` we now longer need the `Properties` on `AnimationEffectTimingProperties` but I decided to try and simplify the names further still.)

The `Partial` naming is based on [`Partial`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html#partial-readonly-record-and-pick) from TypeScript.

The two questions I have before specing this are:

1) Obviously adding `setTiming` and `updateTiming` to `AnimationEffectReadOnly` don't make sense so where should they go? On `KeyframeEffect` itself? Or should we fix this and issue #2068 at the same time?

     For solving #2068 we'd rename the interface `AnimationEffect` and work out how these methods work when applied to animations tied to markup (CSS animations/transitions).

2) Is having `computedDuration` and `computedFill` a bit weird? Is it weird that `activeDuration` is a computed property but `duration` is not? E.g. if you do:
```js
const timing = anim.effect.getTiming();
timing.duration = 3000;
timing.activeDuration = 6000;
anim.effect.updateTiming(timing);
```

only `duration` will have any effect, `activeDuration` will be ignored.

Also, it just occurred to me, might it be useful to have `setTiming` / `updateTiming` return the updated computed timing so you can chain calls together?

I'm not sure if there's a way of expressing partial dictionaries in WebIDL that's less redundant that what I have above.

-- 
GitHub Notification of comment by birtles
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2065#issuecomment-357160686 using your GitHub account

Received on Friday, 12 January 2018 07:13:29 UTC