Skip to content

[web-animations-1] Make animations become idle when they have an inactive timeline #2066

Closed
@birtles

Description

@birtles

From @birtles on November 24, 2016 7:31

In experimenting with scroll-driven timelines we often have the situation where we want the state of the timeline to determine whether animations are in-effect or not. For example, you may want the timeline to be active for a certain scroll range and animations to have no effect outside that range.

This is quite tricky, because I imagine that there are some use cases were you have multiple animations associated with the same ScrollTimeline where you want some to fill backwards and others not to. However, I can't see any combination of timeline and effect fillMode that will produce that result.

That suggests to me that timelines actually have four states:

  • truly inactive -- i.e. some sort of preconditions are not satisfied and the timeline cannot produce any kind of sensible state (this state might not be needed)
  • before start -- i.e. the timeline current time is effectively a hairs' width before zero. Backwards-filling animations associated with it fill backwards, other animations are idle
  • after end -- i.e. the timeline has reached its natural end. Forwards-filling animations associated with it fill forwards, other animations are idle
  • in range -- i.e. playing normally

That analysis might not be right, but whatever approach we take I think we need to have a consistent answer to the following questions:

  • If you play an animation associated with a timeline that is out of its range--what is the state of the animation?
  • If you play an animation not associated with a timeline, what does it do initially, and when you later attach a timeline?
  • If you set the startTime of an animation not associated with a timeline, what does it do initially, and when you later attach a timeline?
  • If you hot-swap timelines, is the current time preserved? And, closely related, do the following code fragments produce the same result:
// A:
anim.timeline = timeline2;
// B:
anim.timeline = null;
anim.timeline = timeline2;
  • Similarly, do animations preserve their state (startTime I guess) when re-attaching to the same timeline. i.e. in what circumstances is the following effectively a no-op:
const timeline = anim.timeline;
anim.timeline = null;
anim.timeline = timeline;

I think we have pretty consistent answers to the above currently, but our answers don't work well with inactive timelines and finite timelines.

We also need to bear in mind the following use cases:

  1. An animation that is idle until its timeline starts to play
  2. An animation that is filling backwards until its timeline starts to play
  3. Likewise for the above at the other end of the timeline
  4. Set the initial playback position of an animation so that when its timeline starts to play, it picks up from that point
  5. Hot-swapping timelines (switch from scroll-based to time-based)
  6. Seek an animation that is not attached to a timeline and get meaningful values out of it

The last one is particularly interesting and would be nice to support if possible (we currently do).

Do we also need to support timelines with multiple independent playback ranges? i.e. are the four states above insufficiently general?

theres-waldo/scroll-driven-animations#1 contains some further details of issues we've hit with this.

Copied from original issue: w3c/web-animations#174

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions