From 2e9391af19fe87f7776e6d0a00ce58c0c9e32f1a Mon Sep 17 00:00:00 2001 From: Michael DiBernardo Date: Tue, 27 Aug 2024 15:45:08 -0400 Subject: [PATCH] Debounce multiple animations when agitating bug. --- main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 308af66..b27df0f 100644 --- a/main.js +++ b/main.js @@ -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");