X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FMoveList.vue;h=e50047d907c952ece8e059c33eddd2adff4fb98e;hb=5fde3a01497262862afc4cb4c9457d4e0ad69a4a;hp=0d9e8d340acf0fb83f27f95698e70bb11e00a153;hpb=f21cd6d9c23da37d729f20ea4c08e56b1a7b10a1;p=vchess.git diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index 0d9e8d34..e50047d9 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -2,23 +2,46 @@ // Component for moves list on the right export default { name: 'my-move-list', - props: ["moves","cursor"], - data: function() { - return { - something: "", //TODO? - }; - }, + 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; - if (this.moves[0].color == "b") - this.moves.unshift({color: "w", notation: "..."}); let tableContent = []; let moveCounter = 0; 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 }, } ) ); @@ -72,17 +101,58 @@ export default { } tableRow.children = moveCells; tableContent.push(tableRow); - const movesTable = h( - "table", - { }, - tableContent - ); - return movesTable; + 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", + { }, + rootElements); }, - methods: { + methods: { gotoMove: function(index) { this.$emit("goto-move", index); }, }, }; + +