From: Benjamin Auder Date: Fri, 6 Mar 2020 18:30:47 +0000 (+0100) Subject: scroll to game beginning: better fix X-Git-Url: https://git.auder.net/doc/html/css/%7B%7B%20path%28%27mixstore_static_policy%27%29%20%7D%7D?a=commitdiff_plain;h=3c18611517fa137f089cbd866cbc8d3f4cc07735;p=vchess.git scroll to game beginning: better fix --- diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index 43570984..da70e349 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -108,13 +108,12 @@ export default { if (window.innerWidth <= 767) return; //scrolling would hide chessboard // $nextTick to wait for table > tr to be rendered this.$nextTick(() => { - let curLine = document.querySelector(".td.highlight-lm"); - if (!!curLine) curLine = curLine.parentNode; - if (!curLine && this.moves.length > 0) + let curMove = document.querySelector(".td.highlight-lm"); + if (!curMove && this.moves.length > 0) // Cursor is before game beginning, and some moves were made: - curLine = document.querySelector(".moves-list .tr:first-child") - if (!!curLine) { - curLine.scrollIntoView({ + curMove = document.querySelector(".moves-list > .tr:first-child > .td"); + if (!!curMove) { + curMove.scrollIntoView({ behavior: "auto", block: "nearest" });