Start/Stop an Animation

Let's learn how to start and stop animation.

We'll cover the following...

Start an animation

The example code defines a function called moveBlock() which moves the block horizontally to the right. It grabs the current position of the block’s left border then adds the value contained in the movement variable. Next, the code calls the requestAnimationFrame() method to keep the animation going.

Position values are ...