Skip to content

Feat/barcode module width resize#58

Merged
u8array merged 3 commits into
mainfrom
feat/barcode-module-width-resize
May 11, 2026
Merged

Feat/barcode module width resize#58
u8array merged 3 commits into
mainfrom
feat/barcode-module-width-resize

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 11, 2026

No description provided.

u8array added 2 commits May 12, 2026 00:02
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.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/components/Canvas/hooks/useKonvaTransformer.ts Outdated
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.
@u8array u8array merged commit da5a3cd into main May 11, 2026
2 checks passed
@u8array u8array deleted the feat/barcode-module-width-resize branch May 11, 2026 22:14
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.

1 participant