Skip to content

Commit

Permalink
Debounce multiple animations when agitating bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDiBernardo committed Aug 27, 2024
1 parent a7c1813 commit 2e9391a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,14 @@ function happyDance(bug) {
}

function agitateBug(event) {
choose(bugClickSounds).play();

const bug = event.currentTarget;
bug.classList.add("pulsing");
if (bug.classList.contains("pulsing")) {
return;
}

choose(bugClickSounds).play();
bug.classList.add("pulsing");

setTimeout(() => {
bug.classList.remove("pulsing");
Expand Down

0 comments on commit 2e9391a

Please # to comment.