Change behavior of slider and add slider label

This commit is contained in:
lolabird 2023-11-09 22:04:04 -07:00
commit 3517cc4e3f
3 changed files with 24 additions and 6 deletions

View file

@ -1,15 +1,18 @@
let numGrid = 16; //will use this later to prompt user
//need to figure out the wrapping issue
const container = document.querySelector(".container");
const conWidth = container.clientWidth;
const grid = document.createElement("div");
const gridSlider = document.querySelector("#gridSlider");
let numGrid = gridSlider.value;
let sliderLabel = document.querySelector("#sliderLabel");
function createGrid() {
const gridArea = numGrid ** 2;
const gridWidth = 100 / numGrid;
sliderLabel.textContent = numGrid
grid.classList.add("grid");
grid.style.width = gridWidth + '%';
grid.style.height = gridWidth + '%';
@ -24,7 +27,7 @@ function createGrid() {
item.addEventListener("mouseover", colorGrid);
});
gridSlider.addEventListener("change", getGridDimensions);
gridSlider.addEventListener("input", getGridDimensions);
}
@ -33,7 +36,6 @@ function getGridDimensions() {
while (container.firstChild) {
container.removeChild(container.lastChild);
}
console.log(numGrid);
createGrid();
}