X-Git-Url: https://git.auder.net/images/pieces/%22%20%20V.getPpath%28board%5Bi%5D%5Bj%5D%29%20%20%20%22.svg?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FMoveList.vue;h=a9fa9834b042e6e6d37244c6fff6aac6c6a29b18;hb=7ddfec38b0804bf0bd0c5b5c6972d355902e9fb0;hp=91d138efb41c1ef7408ec7c7d82565284b7c42a8;hpb=2c5d7b20742b802d9c47916915c1114bcfc9a9c3;p=vchess.git diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index 91d138ef..a9fa9834 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -53,7 +53,7 @@ div | {{ notation(moves[moveIdx]) }} .td( v-if="moveIdx < moves.length-1" - :class="{'highlight-lm': highlightBlackmove(moveIdx)}" + :class="{'highlight-lm': highlightBlackmove(moveIdx+1)}" @click="() => gotoMove(moveIdx+1)" ) | {{ notation(moves[moveIdx+1]) }} @@ -101,10 +101,8 @@ export default { window.addEventListener("resize", () => { if (!timeoutLaunched) { timeoutLaunched = true; - setTimeout(() => { - this.adjustBoard(); - timeoutLaunched = false; - }, 500); + this.adjustBoard(); + setTimeout(() => { timeoutLaunched = false; }, 500); } }); }, @@ -139,8 +137,15 @@ export default { }, highlightBlackmove: function(moveIdx) { return ( - this.cursor == moveIdx + 1 || - (this.show == "byrow" && this.cursor == moveIdx + 2) + this.cursor == moveIdx || + ( + // If display by rows, hightlight last black move while the white + // move is being played: + this.show == "byrow" && + this.cursor == moveIdx + 1 && + // ...except if cursor is behind in the game: + this.cursor == this.moves.length - 1 + ) ); }, gotoMove: function(index) { @@ -149,6 +154,9 @@ export default { adjustBoard: function() { const boardContainer = document.getElementById("boardContainer"); if (!boardContainer) return; //no board on page + let arrows = document.getElementById("arrowCanvas"); + // TODO: arrows on board don't scale + if (!!arrows) this.$emit("reset-arrows"); const k = document.getElementById("boardSize").value; const movesWidth = window.innerWidth >= 768 ? 280 : 0; const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary...