From b94a9ecfd1b20fbc746dd81eb65178eba16cd904 Mon Sep 17 00:00:00 2001 From: Shrihari Magar Date: Fri, 1 Mar 2024 16:37:11 +0530 Subject: [PATCH] fix: event listeners fixed --- app.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 6006005..fd6df58 100644 --- a/app.js +++ b/app.js @@ -117,8 +117,8 @@ function startAnimation() { // check if the grid is empty, // if not then start the animation and start the game if (!areEventListenersremoved) { - areEventListenersremoved = true; removeEventListenersFromCells(); + areEventListenersremoved = true; } const playPauseIcon = document.getElementById("play-pause-icon"); if (isEmpty()) { @@ -172,8 +172,10 @@ function clearGrid() { drawCells(); } isStarted = false; - areEventListenersremoved = false; - addEventListenersToCells(); + if(areEventListenersremoved){ + addEventListenersToCells(); + areEventListenersremoved = false; + } } function animate() {