X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FMoveList.vue;h=e50047d907c952ece8e059c33eddd2adff4fb98e;hb=5fde3a01497262862afc4cb4c9457d4e0ad69a4a;hp=6e2ef66e65057de3196d5504999c050820db2544;hpb=697ee5803b6110b98de0e1097ce6affc712134c4;p=vchess.git diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index 6e2ef66e..e50047d9 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -2,7 +2,36 @@ // Component for moves list on the right export default { name: 'my-move-list', - props: ["moves","cursor"], + props: ["moves","cursor","score","message","firstNum"], + watch: { + cursor: function(newCursor) { + if (window.innerWidth <= 767) + return; //moves list is below: scrolling would hide chessboard + // Count grouped moves until the cursor (if multi-moves): + let groupsCount = -1; + let curCol = undefined; + for (let i=0; i tr to be rendered + this.$nextTick( () => { + let rows = document.querySelectorAll('#movesList tr'); + if (rows.length > 0) + { + rows[Math.floor(Math.max(groupsCount,0)/2)].scrollIntoView({ + behavior: "auto", + block: "nearest", + }); + } + }); + }, + }, render(h) { if (this.moves.length == 0) return; @@ -11,7 +40,8 @@ export default { let tableRow = undefined; let moveCells = undefined; let curCellContent = ""; - for (let i=0; i this.gotoMove(i) }, - "class": { "highlight-lm": this.cursor == i }, + "class": { "highlight-lm": + this.cursor >= firstIndex && this.cursor <= i }, } ) ); @@ -65,21 +101,58 @@ export default { } tableRow.children = moveCells; tableContent.push(tableRow); - const movesTable = h( + let rootElements = []; + if (this.score != "*") + { + const scoreDiv = h("div", + { + id: "scoreInfo", + style: { + display: this.score!="*" ? "block" : "none", + }, + }, + [ + h("p", this.score), + h("p", this.message), + ] + ); + rootElements.push(scoreDiv); + } + rootElements.push( + h( + "table", + { + "class": { + "moves-list": true, + }, + }, + tableContent + ) + ); + return h( "div", { }, - [h( - "table", - { }, - tableContent - )] - ); - return movesTable; + rootElements); }, - methods: { + methods: { gotoMove: function(index) { this.$emit("goto-move", index); }, }, }; + +