From 444615475746b98a4338de2a6bb9e70f5735780b Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Tue, 4 Dec 2018 16:54:03 +0100 Subject: [PATCH] Fix mousedown event (only in game) --- public/javascripts/components/game.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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")) { -- 2.44.0