Feat/barcode module width resize#58
Merged
Merged
Conversation
Enables middle-left / middle-right transformer anchors for 1D barcodes (whose width is content × moduleWidth × byRatio and has no free-form width property). The bbox snaps to integer moduleWidth multiples during the drag so the bitmap only jumps when the cursor crosses a module boundary, and commitBarcodeWidthHeightTransform records the new moduleWidth (clamped to the ZPL ^BY range 1..10) alongside any sy-driven height change. Rotation is handled by Konva natively: the anchors are defined in node-local coords, so the transformer renders them at the visually correct end of the rotated bbox and sx still applies to the local bar-axis. FT-positioned barcodes have a pre-existing position drift on resize (documented in transformPosition.ts) that this commit does not yet fix — follow-up.
Two changes from the post-feature audit: 1. FT-positioned 1D barcodes used to drift upward on every resize: the transformer-end logic treated the rendered bbox top as the new obj.y, but ^FT anchors at the bar baseline (= bbox bottom). The stored y was therefore the *previous* top, and the next render subtracted bar-height again, shifting the symbol upward by a bar height per resize. Pass the post-resize bar height through to modelPositionFromRenderedTopLeft and add it back when the object is FT-positioned. 2. The barcodeAnchorRef + boundBoxFunc width snap that was meant to make the bbox jump in integer-moduleWidth steps during the drag never actually fired — node.width() returns 0 for a Konva.Group so the guard always fell through. Free-form stretch during the drag with commit-time rounding turns out to be the more natural UX anyway (matches how every other shape resize behaves), so the dead code path is removed rather than fixed. Drops the now-unused commitHeightTransform helper at the same time.
There was a problem hiding this comment.
Code Review
This pull request enables horizontal resizing for 1D barcodes by adding side handles and implementing module width scaling. It also corrects vertical drift for FT-anchored barcodes during resizing by accounting for the bar height in position calculations. The reviewer suggested applying grid snapping to the temporary height calculation for FT-anchored barcodes to maintain consistency with the final committed state and prevent minor positioning errors.
Gemini noted that the newBarHeightDots used for the FT baseline math read the raw scaled prop while commitBarcodeWidthHeightTransform stores it snapped to grid — a 1-dot drift between the two paths. Pipe the value through the same snap() so the position math sees exactly what gets committed.
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.
No description provided.