Skip to content

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

Open
@majido

Description

@majido

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions