From: Benjamin Auder Date: Fri, 31 Jan 2020 22:18:14 +0000 (+0100) Subject: Last size adjustments X-Git-Url: https://git.auder.net/variants/Chakart/img/doc/pieces/css/index.css?a=commitdiff_plain;h=d36ca1989daec86e5ad4b2e65c8a045af171fafd;p=vchess.git Last size adjustments --- diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 04aff149..f4900435 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -90,20 +90,6 @@ export default { document.getElementById("boardContainer").style.width = boardSize + "px"; let gameContainer = document.getElementById("gameContainer"); gameContainer.style.width = (boardSize + movesWidth) + "px"; - - - - - - // TODO: something here........... gameContainer.width increases if from small to larger screen - window.onResize = (e) => { - console.log(e); - //if (window.innerWidth >= 768) - }; - - - - }, methods: { focusBg: function() { diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index ca538924..1209dd99 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -3,7 +3,7 @@ div #scoreInfo(v-if="score!='*'") p {{ score }} p {{ message }} - table#movesList + table.moves-list tbody tr(v-for="moveIdx in evenNumbers") td {{ firstNum + moveIdx / 2 + 1 }} @@ -25,6 +25,8 @@ export default { props: ["moves","cursor","score","message","firstNum"], watch: { cursor: function(newValue) { + if (window.innerWidth <= 767) + return; //moves list is below: scrolling would hide chessboard if (newValue < 0) newValue = 0; //avoid rows[-1] --> error // $nextTick to wait for table > tr to be rendered diff --git a/client/src/components/Settings.vue b/client/src/components/Settings.vue index 5d038865..d08b943f 100644 --- a/client/src/components/Settings.vue +++ b/client/src/components/Settings.vue @@ -51,6 +51,18 @@ export default { const boardSize = localStorage.getItem("boardSize"); if (!!boardSize) document.getElementById("myRange").value = Math.floor(boardSize / 10); + // timeout to avoid calling too many time the adjust method + let timeoutLaunched = false; + window.addEventListener("resize", (e) => { + if (!timeoutLaunched) + { + timeoutLaunched = true; + setTimeout( () => { + this.adjustBoard(); + timeoutLaunched = false; + }, 500); + } + }); }, methods: { updateSettings: function(event) { @@ -65,14 +77,15 @@ export default { if (!boardContainer) return; //no board on page const k = document.getElementById("myRange").value; - const movesWidth = (window.innerWidth >= 768 ? 280 : 0); //TODO: constant somewhere...; + const movesWidth = (window.innerWidth >= 768 ? 280 : 0); const minBoardWidth = 240; //TODO: same // Value of 0 is board min size; 100 is window.width [- movesWidth] const boardSize = minBoardWidth + k * (window.innerWidth - (movesWidth+minBoardWidth)) / 100; localStorage.setItem("boardSize", boardSize); boardContainer.style.width = boardSize + "px"; - document.getElementById("gameContainer").style.width = (boardSize + movesWidth) + "px"; + document.getElementById("gameContainer").style.width = + (boardSize + movesWidth) + "px"; }, }, };