Open
Description
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.
new WorkletAnimation('foo', [new KeyframeEffect(...)], scrollTimeline, {'documentTime': document.timeline});
Then we could allow attaching to / detaching from additional timelines within the object. For example:
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