Fix grid snapping to use Math.round for consistent nearest-snap behavior #3

Merged
Chocolateandmilkwin merged 1 commit from copilot/fix-snapping-logic-viewport-mover into main 2026-04-09 10:17:33 +00:00
Chocolateandmilkwin commented 2026-04-09 10:17:11 +00:00 (Migrated from github.com)

Replace value - (value % grid) with Math.round(value / grid) * grid for position X, position Y, and rotation snapping. This ensures:

  • Snapping occurs at the halfway point between grid lines
  • Consistent behavior for both positive and negative coordinates

Agent-Logs-Url: https://github.com/chocbite/ts-lib-canvas/sessions/571f5923-2ede-4684-954b-cb5c7d12280f

Co-authored-by: Chocolateandmilkwin 52867415+Chocolateandmilkwin@users.noreply.github.com

Replace `value - (value % grid)` with `Math.round(value / grid) * grid` for position X, position Y, and rotation snapping. This ensures: - Snapping occurs at the halfway point between grid lines - Consistent behavior for both positive and negative coordinates Agent-Logs-Url: https://github.com/chocbite/ts-lib-canvas/sessions/571f5923-2ede-4684-954b-cb5c7d12280f Co-authored-by: Chocolateandmilkwin <52867415+Chocolateandmilkwin@users.noreply.github.com>
Sign in to join this conversation.
No description provided.