X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=80a79a4a294d2209c6d9365ac964f3f7bc19ce5c;hb=616561273f216debfeab7f5fc532d0b0a8bc8e2d;hp=71cac153d9d11b93e73352310c1643baf899448b;hpb=0a9cef131612079e55714f56f1466b4e2bd749af;p=vchess.git diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 71cac153..80a79a4a 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -388,9 +388,15 @@ export default { mousedown: function(e) { e.preventDefault(); if (!this.start) { - // Start square must contain a piece. // NOTE: classList[0] is enough: 'piece' is the first assigned class - if (e.target.classList[0] != "piece") return; + const withPiece = e.target.classList[0] == "piece"; + // Emit the click event which could be used by some variants + this.$emit( + "click-square", + getSquareFromId(withPiece ? e.target.parentNode.id : e.target.id) + ); + // Start square must contain a piece. + if (!withPiece) return; let parent = e.target.parentNode; //surrounding square // Show possible moves if current player allowed to play const startSquare = getSquareFromId(parent.id);