X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;fp=client%2Fsrc%2Fcomponents%2FBoard.vue;h=b176bd73221d0e6abb0beb81a095ed69b023e4d1;hp=cc3f6fd7d7a51fd5053f6c7483edf0a07c8b1609;hb=cbe9537881e68f50c43f48d3699c4b248690fb4d;hpb=1328e7dd5a73fd4a4eee85d5b86aea73b9a74f9f diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index cc3f6fd7..b176bd73 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -663,27 +663,29 @@ export default { this.$emit("click-square", sq); if (withPiece && !this.vr.onlyClick(sq)) { this.possibleMoves = this.vr.getPossibleMovesFrom(startSquare); - // For potential drag'n drop, remember start coordinates - // (to center the piece on mouse cursor) - let parent = e.target.parentNode; //surrounding square - const rect = parent.getBoundingClientRect(); - this.start = { - x: rect.x + rect.width / 2, - y: rect.y + rect.width / 2, - id: parent.id - }; - // Add the moving piece to the board, just after current image - this.selectedPiece = e.target.cloneNode(); - Object.assign( - this.selectedPiece.style, - { - position: "absolute", - top: 0, - display: "inline-block", - zIndex: 3000 - } - ); - parent.insertBefore(this.selectedPiece, e.target.nextSibling); + if (this.possibleMoves.length > 0) { + // For potential drag'n drop, remember start coordinates + // (to center the piece on mouse cursor) + let parent = e.target.parentNode; //surrounding square + const rect = parent.getBoundingClientRect(); + this.start = { + x: rect.x + rect.width / 2, + y: rect.y + rect.width / 2, + id: parent.id + }; + // Add the moving piece to the board, just after current image + this.selectedPiece = e.target.cloneNode(); + Object.assign( + this.selectedPiece.style, + { + position: "absolute", + top: 0, + display: "inline-block", + zIndex: 3000 + } + ); + parent.insertBefore(this.selectedPiece, e.target.nextSibling); + } } } }