X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FMoveList.vue;h=e50047d907c952ece8e059c33eddd2adff4fb98e;hb=5fde3a01497262862afc4cb4c9457d4e0ad69a4a;hp=fa01cf16b0a3423a83b981144bfcd69f58fbf03f;hpb=cf2343cee5729c011770ace6d5b4f79d1ac3a2b6;p=vchess.git diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index fa01cf16..e50047d9 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -2,28 +2,46 @@ // Component for moves list on the right export default { name: 'my-move-list', - props: ["moves","cursor"], //TODO: other props for e.g. players names + connected indicator - // --> we could also add turn indicator here - data: function() { - return { - something: "", //TODO? - }; - }, - // TODO: extend rendering for more than 2 colors: would be a parameter - // in that case some moves for some colors could be just skipped (if a player lost) + 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; - const nbColors = 2; - // TODO: name colors "white", "black", "red", "yellow" ? - 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 }, } ) ); @@ -66,32 +90,69 @@ export default { } } // Complete last row, which might not be full: - if (moveCells.length-1 < nbColors) + if (moveCells.length-1 == 1) { - const delta = nbColors - (moveCells.length-1); - for (let i=0; i + +