8000 Add zoom and pan to the trace polygon editor by jasonmadigan · Pull Request #147 · tracefinity/tracefinity · GitHub
[go: up one dir, main page]

Skip to content

Add zoom and pan to the trace polygon editor - #147

Merged
jasonmadigan merged 3 commits into
mainfrom
98-polygon-editor-zoom-pan
Jul 26, 2026
Merged

jasonmadigan merged 3 commits into
mainfrom
98-polygon-editor-zoom-pan

Conversation

@jasonmadigan
Copy link
Copy Markdown
Collaborator

Summary

Adds cursor-centred wheel zoom (0.5x to 20x) and pan (middle-mouse or Space+LMB, grabbing cursor) to the trace polygon editor, matching ToolEditor's viewBox interaction model. The corrected photo moves inside the SVG so image and overlay transform together; handle and stroke sizes stay constant on screen. Zoom controls pill with fit and percentage, same placement as ToolEditor.

Closes #98

Implementation

  • New frontend/src/lib/viewbox.ts with pure viewBox/clamp/cursor-zoom maths, unit tested
  • getScaledPoint maps pointer events through the zoomed viewBox
  • did-pan guard stops a pan release triggering deselect, polygon select or add-vertex
  • Shared ZOOM_FACTOR; MIN_ZOOM/MAX_ZOOM exported and pinned in tests

Test evidence

  • vitest: 107/107 (12 new in viewbox.test.ts)
  • eslint 0 errors (9 pre-existing warnings, none in changed files), tsc clean, pnpm build green
  • Self-review verified the 11 acceptance criteria from the issue spec
  • Manual-only: gesture feel, touch drag, wheel scroll suppression

Follow-ups noted in review, out of scope here: spaceHeld sticking across window blur (ToolEditor shares it), migrating ToolEditor to the shared zoom constants, mousemove listener re-registration during pan.

Refs #98

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
Cursor-centred wheel zoom (0.5x-20x), middle-mouse or Space+left-drag
pan with a did-pan guard on all click paths, photo moved inside the
SVG so it tracks the viewBox, constant on-screen handle sizes, and a
zoom pill matching ToolEditor. Zoom and pan never enter undo history.

Closes #98

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
@jasonmadigan
jasonmadigan marked this pull request as ready for review July 26, 2026 14:29
@jasonmadigan
jasonmadigan merged commit 67437c7 into main Jul 26, 2026
4 checks passed
@jasonmadigan
jasonmadigan deleted the 98-polygon-editor-zoom-pan branch July 26, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Navigation

1 participant

0