Repository navigation
Add zoom and pan to the trace polygon editor - #147
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
frontend/src/lib/viewbox.tswith pure viewBox/clamp/cursor-zoom maths, unit testedgetScaledPointmaps pointer events through the zoomed viewBoxZOOM_FACTOR;MIN_ZOOM/MAX_ZOOMexported and pinned in testsTest evidence
viewbox.test.ts)pnpm buildgreenFollow-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.