Compare commits

..

No commits in common. "oob-checking" and "master" have entirely different histories.

View File

@ -164,35 +164,15 @@ window.addEventListener("mousedown", event => {
draw(); draw();
}); });
function columnContainsOnlyUnrevealed(column) {
return column.every(cell => !cell.isRevealed);
}
window.addEventListener("wheel", event => { window.addEventListener("wheel", event => {
let deltaX = 0, deltaY = 0;
if (event.shiftKey) { if (event.shiftKey) {
deltaX = event.deltaY; scrollX += event.deltaY;
} else { } else {
deltaX = event.deltaX; scrollX += event.deltaX;
deltaY = event.deltaY; scrollY += event.deltaY;
} }
console.log(scrollY + deltaY + window.innerHeight, board.length * CELL_SIZE); // TODO create new rows/columns on scroll
if (scrollY + deltaY + window.innerHeight > board.length * CELL_SIZE) {
if (board.slice(-20).every(columnContainsOnlyUnrevealed)) {
console.log("ignoring");
return;
}
const diff = scrollY + window.innerHeight - board.length * CELL_SIZE;
for (let i = 0; i < diff + CELL_SIZE; i += CELL_SIZE)
createRowAtBottom();
}
scrollX += deltaX;
scrollY += deltaY;
draw(); draw();
}); });