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

There is two part this proposal:
 
1. Make one timeline a primary timeline. 
2. Allow animation to explicitly attach/detach to timelines.

I support both these ideas but let me add more color to the discussion.

# A Primary Timeline
The main benefit here is that it will make integration with Web Animation much simpler. For example it is now clear what is the time value that will be used in the animation events i.e., [**event timeline time**](http://w3c.github.io/web-animations/#event-timeline-time).

# Explicit Timeline Attach/Detach
Our previous design was passing multiple timelines to the animation. An issue with that design is that the animation needed to be updated anytime **any** of its timelines has changed. However, this is inefficient in many common usecases. Take for example the “hidy bar” effect  where the animation initially tracks the scroll offset (via `ScrollTimeline`) but as soon as the finger is lifted it continues the animated effect by tracking time (via `DocumentTimeline`). So in the first phase the animation needs to only be responsive to scroll offset changes and in seconds phase it needs to be responsive to both scroll offset and time. So in this case, if we had both timelines at the beginning then we would need to call animate function every frame even if there was no scrolling in that frame! 

The explicit attach/detach idea help solve this issue. In particular, the animation will get all its needed timelines (primary, and those in options bag) during its construction. Then it can attach/detach to them as needed and its update rate is determined by its **attached timelines**.

So here is the proposal in more concrete terms:

- Attaching an animation to a timeline means that it will be updated if the timeline `currentTime` value changes
- `WorkletAnimation` can explicitly attach itself to any timeline it has a reference to. 
- On initialization, a `WorkletAnimation` is attached to its primary timeline but not attached to other timeline that it received via its options bag.
- The animation may still read the `currentTime` value of its detached timelines.



-- 
GitHub Notification of comment by majido
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/810#issuecomment-417053749 using your GitHub account

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