snap to cursor on click

This commit is contained in:
Adam Jeniski 2026-01-02 14:32:09 -05:00
parent ac81079c5a
commit a546fe38b7

View File

@ -77,8 +77,7 @@
} }
function handleCanvasClick(event) { function handleCanvasClick(event) {
// If we're about to turn off tracking, update position one last time // Update position at click location before toggling tracking
if (trackHover) {
const rect = canvas.getBoundingClientRect(); const rect = canvas.getBoundingClientRect();
const mouseX = event.clientX - rect.left; const mouseX = event.clientX - rect.left;
const mouseY = event.clientY - rect.top; const mouseY = event.clientY - rect.top;
@ -88,7 +87,6 @@
x: Math.floor((mouseX + GRID_SIZE / 2) / GRID_SIZE), x: Math.floor((mouseX + GRID_SIZE / 2) / GRID_SIZE),
y: Math.floor((HEIGHT - mouseY + GRID_SIZE / 2) / GRID_SIZE) y: Math.floor((HEIGHT - mouseY + GRID_SIZE / 2) / GRID_SIZE)
}; };
}
trackHover = !trackHover; trackHover = !trackHover;
} }