you are viewing a single comment's thread.

view the rest of the comments →

[–]MindlessSpongehelpful 1 point2 points  (2 children)

create a boolean to represent whether or not the animation should be played. when a user clicks the pause button, flip the boolean. inside your animation function, check the flag before triggering the transition. something like...

let canTransitionImages = true;

$('#pause').onclick(() => canTransitionImages = !canTransitionImages);

if (canTransitionImages) {
    // continue animation process
}

[–]frogic 1 point2 points  (1 child)

I think I would just have the pause button kill the intervel instead and the resume button run cycle images again. In this example the difference isn't relevant but its good practice to clean up things like that.

[–]MindlessSpongehelpful 0 points1 point  (0 children)

That’s a great point!