Docs
Playing clips
One-shots, loops, chaining and speed: how play() behaves and what its promise means.
play(name) starts a clip and returns a promise that resolves when the clip is back on the still picture. The element then stays on that still. A clip made as a loop keeps playing until another clip starts.
await coin.play('spin'); // one-shot, resolves on the still
await coin.play('pop', { speed: 2 }); // twice as fast
console.log(coin.clips); // ['win', 'idle', 'spin', ...]Chaining
Every clip starts and ends on the same still, so any clip can follow any other without a jump. Starting a clip while another plays replaces it at once.
The promise always resolves
If the element is destroyed mid-clip, its promise still resolves. A sequence awaiting a clip never hangs. Asking for a clip the element does not have rejects with the list of clips it has.