X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBaseGame.vue;h=aa606aa57f4946c851a3d1ba3f37573efadb4eb9;hb=a0c41e7e23c9ff64031739e072f38e493bac8dca;hp=523e0ef6d89061efd5734bfca1a72b8f46572746;hpb=9335d45b03966f433df8dd84ec31e8a22585a97f;p=vchess.git diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 523e0ef6..aa606aa5 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -81,7 +81,6 @@ export default { this.re_setVariables(); }, // Received a new move to play: - // TODO: error "flush nextTick callbacks" when observer reloads page "game.moveToPlay": function(newMove) { if (!!newMove) //if stop + launch new game, get undefined move this.play(newMove, "receive"); @@ -223,6 +222,7 @@ export default { const L = this.moves.length; this.cursor = L-1; this.lastMove = (L > 0 ? this.moves[L-1] : null); + this.incheck = []; }, analyzePosition: function() { const newUrl = "/analyze/" + this.game.vname + @@ -273,12 +273,18 @@ export default { }, animateMove: function(move, callback) { let startSquare = document.getElementById(getSquareId(move.start)); + // TODO: error "flush nextTick callbacks" when observer reloads page: + // this late check is not a fix! + if (!startSquare) + return; let endSquare = document.getElementById(getSquareId(move.end)); let rectStart = startSquare.getBoundingClientRect(); let rectEnd = endSquare.getBoundingClientRect(); let translation = {x:rectEnd.x-rectStart.x, y:rectEnd.y-rectStart.y}; let movingPiece = document.querySelector("#" + getSquareId(move.start) + " > img.piece"); + if (!movingPiece) //TODO: shouldn't happen + return; // HACK for animation (with positive translate, image slides "under background") // Possible improvement: just alter squares on the piece's way... const squares = document.getElementsByClassName("board");