web-animations / web-animations-js

JavaScript implementation of the Web Animations API
http://web-animations.github.io
Apache License 2.0
3.77k stars 408 forks source link

DocumentTimeline not implemented #228

Open ysulyma opened 3 years ago

ysulyma commented 3 years ago

I need to attach animations to a DocumentTimeline other than the default document.timeline. However, the polyfill does not implement/expose this constructor.

Use case: I have a player for "videos" made out of HTML/React. The video player has its own timeline; if an animation is attached to the video timeline with delay, say, 2000, then the animation will happen at the 2 second mark in the video. This is achieved by scheduling the animation at the corresponding future time on the actual document timeline and adjusting whenever the user seeks.

The timeline syncing code is https://github.com/ysulyma/ractive-player/blob/v2.1/src/playback.ts#L242

Minimal working example: https://ractive-player.org/r/timeline/. Press play, and "Hello World" should fade in after 2 seconds.

(Probably) separate issue: the above works correctly in Firefox and Chrome, but not in iOS 12 (which doesn't implement the Web Animations API). However, if I include 2.3.2/web-animations-next.min.js, then it stops working in Firefox and Chrome, even though they implement the Web Animations API.