gridCellNumbers static HTML

turned the createGridSection() function in style that created an HTML for the text labels in gridOverlay inside the JS with javascript dynamic to static HTML in index.html.
This commit is contained in:
Ángel Montero Lamas 2024-09-14 21:06:30 +02:00
parent b2ce493e40
commit a2e1004734
3 changed files with 19 additions and 29 deletions

View file

@ -1414,6 +1414,9 @@ function toggleGrid(event) {
turnButtonOff("toggleGrid");
gridOverlay.selectAll("*").remove();
}
// Update the checkbox state when toggling the grid
document.getElementById("gridCellNumbers").checked = gridOverlay.attr("cell-numbers") === "true";
}
function drawGrid() {
@ -1443,11 +1446,15 @@ function drawGrid() {
.attr("height", maxHeight)
.attr("fill", "url(" + pattern + ")")
.attr("stroke", "none");
if (gridOverlay.attr("cell-numbers") === "true") {
drawCellNumbers();
}
// Check both the attribute and the checkbox state
if (gridOverlay.attr("cell-numbers") === "true" || document.getElementById("gridCellNumbers").checked) {
drawCellNumbers();
}
}
function drawCellNumbers() {
const pattern = gridOverlay.attr("type") || "pointyHex";
const scale = +gridOverlay.attr("scale") || 1;