Solution Review: Spinning Animation
This lesson provides a detailed explanation to the previous challenge.
In the previous challenge, you were asked to create a rotation animation which could be triggered multiple times when the target element was clicked.
Step 1: Add a flag and a function to start and stop spinning
Create a variable, isSpinning
,to trigger the spin animation (line 11). We can then add the functions startSpinning
and stopSpinning
to toggle between the two states (lines 13–22).
Get hands-on with 1200+ tech skills courses.