From 166d36cd9381b40d38c266500c8fe36e1b5ab1b2 Mon Sep 17 00:00:00 2001 From: Trevor Tao <95892589+hilarioushappystar@users.noreply.github.com> Date: Fri, 10 Dec 2021 19:49:14 +1030 Subject: [PATCH] Update dragEvent.js BUG FIX: move counter is not incremented (also no pop sound) when we move 1 or more cards to an empty column --- js/dragEvent.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/dragEvent.js b/js/dragEvent.js index 6d8f08d..0e26eeb 100644 --- a/js/dragEvent.js +++ b/js/dragEvent.js @@ -101,9 +101,14 @@ function DragEvents() { if (!this.container || this.container === source) return; - if ( !this.container.children[0] ) + if ( !this.container.children[0] ) { + noOfMoves++; + var moves = document.getElementById("score"); + moves.innerHTML = noOfMoves; + popSound = new Sound('audio/pop.mp3'); + popSound.play(); return this.container; - + } var cardNum1 = +target.dataset.card.slice(1); //Returns only a number that can be compared --> Represents target var cardNum2 = +this.container.lastElementChild.dataset.card.slice(1); // Represents last element of new parent if ( cardNum1 + 1 == cardNum2 ) { @@ -119,4 +124,4 @@ function DragEvents() { }; -} \ No newline at end of file +}