X-Git-Url: https://git.auder.net/pieces/Checkered/cq.svg?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=6c26722a4420e73885966196b25db5af90bb4aa3;hb=fef153df51fe60a5af4c5b2a05e0b1177187bf62;hp=639938b2b4b14ead23db62715fe46f7c811be27e;hpb=5f918a278904266a2a66a3c8e2a3655f37c2d2a7;p=vchess.git diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 639938b2..6c26722a 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -519,12 +519,11 @@ export default { }; }, mousedown: function(e) { - if (!([1, 3].includes(e.which))) return; e.preventDefault(); - if (e.which != 3) + if (!this.mobileBrowser && e.which != 3) // Cancel current drawing and circles, if any this.cancelResetArrows(); - if (e.which == 1 || this.mobileBrowser) { + if (this.mobileBrowser || e.which == 1) { // Mouse left button if (!this.start) { // NOTE: classList[0] is enough: 'piece' is the first assigned class @@ -566,8 +565,8 @@ export default { } else { this.processMoveAttempt(e); } - } else { - // e.which == 3 : mouse right button + } else if (e.which == 3) { + // Mouse right button let elem = e.target; // Next loop because of potential marks while (elem.tagName == "IMG") elem = elem.parentNode; @@ -612,21 +611,27 @@ export default { } }, mouseup: function(e) { - if (!([1, 3].includes(e.which))) return; e.preventDefault(); - if (e.which == 1) { + if (this.mobileBrowser || e.which == 1) { if (!this.selectedPiece) return; // Drag'n drop. Selected piece is no longer needed: this.selectedPiece.parentNode.removeChild(this.selectedPiece); delete this.selectedPiece; this.selectedPiece = null; this.processMoveAttempt(e); - } else { - // Mouse right button (e.which == 3) + } else if (e.which == 3) { + // Mouse right button this.movingArrow = { x: -1, y: -1 }; this.processArrowAttempt(e); } }, + // Called by BaseGame after partially undoing multi-moves: + resetCurrentAttempt: function() { + this.possibleMoves = []; + this.start = null; + this.click = ""; + this.selectedPiece = null; + }, processMoveAttempt: function(e) { // Obtain the move from start and end squares const [offsetX, offsetY] =