feat(line): smart axis snap + quick-orientation picker#48
Merged
Conversation
Endpoint editing: - onDragMove and onDragEnd both project the cursor onto a constrained axis so the line visually stays on a rail during the drag instead of only snapping at release. Length matches the axial component of the drag (Figma / Sketch convention) rather than the diagonal Euclidean distance. - Default behaviour: Figma-style auto-snap to the nearest 45° step when the raw angle is within ±5°, otherwise free. - Shift always forces an explicit 45°-step constraint. Quick-orientation picker in the Properties panel: - Four buttons (—, |, /, \) rendered as inline 12×12 SVGs for crisp, font-independent icons. - Buttons pick the candidate angle closest to the line's current angle so the line keeps its rough direction. Repeated click on the active orientation flips the line 180° (e.g. 0° ↔ 180°). - View-rotation aware: candidates are expressed as on-screen angles, then converted to label-space by subtracting the current view rotation. Clicking '—' always yields a visually horizontal line. - Length is preserved (no projection collapse when rotating).
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized line constraint system with free, shift, and auto-snap modes, refactoring the LineObject component to use a new projection utility. It also adds an orientation picker to the line properties panel that remains accurate under canvas rotation and includes updated translations for multiple locales. Feedback suggests enhancing the orientation picker's toggle logic by using angular distance instead of strict equality to prevent issues with angle normalization.
Reviewer-spotted (gemini-code-assist on PR #48): with strict ===, an angle entered as -270° in the NumberInput would not match candidate 90° even though they are the same orientation, so the second-click flip would silently fall through to the nearest-pick branch. Use angleDistance with a 0.5° tolerance for the match check; preserve the existing <= tie-breaking on the nearest-pick fall-through so the already-pinned 'tie → first candidate' behaviour stays.
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.
Endpoint editing:
Quick-orientation picker in the Properties panel: