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() {
#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 }}
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
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) {
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";
},
},
};