From: Benjamin Auder Date: Tue, 4 Dec 2018 15:54:03 +0000 (+0100) Subject: Fix mousedown event (only in game) X-Git-Url: https://git.auder.net/?p=vchess.git;a=commitdiff_plain;h=444615475746b98a4338de2a6bb9e70f5735780b Fix mousedown event (only in game) --- diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 84976b0c..2a9a7018 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -736,6 +736,19 @@ Vue.component('my-game', { }, mousedown: function(e) { e = e || window.event; + let ingame = false; + let elem = e.target; + while (!ingame && elem !== null) + { + if (elem.classList.contains("game")) + { + ingame = true; + break; + } + elem = elem.parentElement; + } + if (!ingame) //let default behavior (click on button...) + return; e.preventDefault(); //disable native drag & drop if (!this.selectedPiece && e.target.classList.contains("piece")) {