update point B position on click before freezing tracking

This commit is contained in:
Adam Jeniski 2026-01-02 11:52:20 -05:00
parent 542b72b6a8
commit 323a767abc

View File

@ -76,7 +76,20 @@
};
}
function handleCanvasClick() {
function handleCanvasClick(event) {
// If we're about to turn off tracking, update position one last time
if (trackHover) {
const rect = canvas.getBoundingClientRect();
const mouseX = event.clientX - rect.left;
const mouseY = event.clientY - rect.top;
// Add half grid unit offset for snapping to closest grid intersection
userPoint = {
x: Math.floor((mouseX + GRID_SIZE / 2) / GRID_SIZE),
y: Math.floor((HEIGHT - mouseY + GRID_SIZE / 2) / GRID_SIZE)
};
}
trackHover = !trackHover;
}