[css-houdini-drafts] Pass additional timelines as part of additional options and only have a single timeline in constructor.

majido has just created a new issue for https://github.com/w3c/css-houdini-drafts:

== Pass additional timelines as part of additional options and only have a single timeline in constructor. ==
_From @flackr on July 20, 2017 19:31_

I think WorkletAnimation would be more consistent with Web Animations if we just passed the primary timeline in the constructor and moved additional timelines to the additional options bag.

i.e.
```javascript
new WorkletAnimation('foo', [new KeyframeEffect(...)], scrollTimeline, {'documentTime': document.timeline});
```

Then we could allow attaching to / detaching from additional timelines within the object. For example:

```javascript
registerAnimator('twitter-header', class {
  constructor(options) {
    this.options_ = options;
  }

  animate(timeline, effect) {
    ...
    if (condition) {
      this.options_.documentTime.attach(this);
      // Or this.attach(this.options_.documentTime);
      // At this point in time the animation will now tick with the DocumentTimeline as well
      // as the ScrollTimeline.
    } else if (other_condition) {
      // detach from document timeline.
    }
  }
});
```

It's also possible that since there is a single DocumentTimeline it may be available on the global scope to attach to / detach from.

_Copied from original issue: WICG/animation-worklet#61_

Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/810 using your GitHub account

Received on Wednesday, 29 August 2018 18:19:07 UTC