Learning more about queuing and playing animation segments
When we queue an animation segment, we pass it a duration, cue points, and keyframes. But we can also pass in other options that affect the playback of the animation segment. We can also call methods on the animation object that affect animation segments currently playing and in the queue.
Before we start messing with these, copy the content of easing-animations.js
into a new file called playing-with-the-queue.js
. Remove the call to myFirstAnimation.enqueue()
at the end; we want a little control when we get into the REPL this time around.
Â
Looping animation segments
First, let's add a function that will enqueue our animation normally:
function playMyAnimation() { myFirstAnimation.enqueue({ keyFrames: keyframes, duration: duration, cuePoints: cuePoints }) }
Sometimes you want the animation segment you are enqueuing to run on a loop. Let's create a function in our board.on('ready')
handler that will enqueue our animation...