Skip to content

Dragging a side of the spacing box sizes and labels the canvas band from the dragged value - #38

Merged
flowtricks merged 1 commit into
flowtricks:mainfrom
LilianBarbe:spacing-band-follows-drag
Oct 13, 2026
Merged

flowtricks merged 1 commit into
flowtricks:mainfrom
LilianBarbe:spacing-band-follows-drag

Conversation

@LilianBarbe

Copy link
Copy Markdown
Contributor

The problem

Dragging a side of the spacing box runs the panel's number through every value on the way, but the band drawn over the page does not follow:

  • Its label comes from the hover, which reads the file. It keeps the old value for the whole drag: "2rem" on the band under a number already at 3.
  • Its size comes from the page as last measured. The value has to be written, laid out and reported back, so the band runs a few frames behind and skips whatever the page had no time to lay out.

The change

The drag tells the canvas its value on the frame the panel's labels change: labels and a new live on SpacingHover, for the sides Shift and Alt bring in.

The canvas turns that value into pixels itself and draws the band that size at once. The page now reports, alongside its measurements, what one em, rem, vw and vh is worth for the element (units). A percentage, a variable or a calc() keeps the measurement, since only the page can size those. An inset (top on a positioned element) is labelled but measured.

The hover is silent while a drag reports, so a modifier pressed mid-drag cannot put the file's value back on the band. On release the label stays and the size is measured again, which by then is the same number.

Contract

units is a new optional field on each spacing entry of the avb:rects message, parsed in previewMessages.ts as a dictionary of nonnegative finite numbers. A page served by an older preload still parses; its bands are measured, as before.

Tests

  • test/renderer/preview/spacingLive.test.js: the conversion to pixels, including the values that must not be guessed, and the band drawn from it.
  • test/renderer/style/spacingDragReport.test.js: the real EmbedEditor in jsdom. A drag reports its value on each frame, with Shift bringing in the four sides, and no report between press and release carries the file's value.
  • test/renderer/preview/previewMessages.test.js: units in the known-good message, and three malformed shapes that are refused.
  • npm run check:changed passes.

🤖 Generated with Claude Code

Dragging a side of the spacing box runs the panel's number through every
value on the way, but the band drawn over the page did not follow. Its
label came from the hover, which reads the file, so it kept the old value
for the whole drag ("2rem" under a number already at 3). Its size came
from the page as last measured: the value had to be written, laid out and
reported back, a few frames behind and skipping whatever the page had no
time to lay out.

The drag now tells the canvas its value on the frame the labels change
(`labels` and `live` on SpacingHover, for the sides Shift and Alt bring
in). The canvas turns it into pixels itself, with the units the page now
reports alongside its measurements (em is the element's font, rem the
root's, vw and vh the frame), and draws the band that size at once. A
percentage, a variable or a calc() keeps the measurement: only the page
can size those. An inset (`top` on a positioned element) is labelled but
measured.

The hover is silent while a drag reports, so a modifier pressed mid-drag
cannot put the file's value back on the band. On release the label stays
and the size is measured again, which by then is the same number.

`units` is optional in the rects message, so a page served by an older
preload still parses; its bands are measured, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@flowtricks
flowtricks merged commit 3469c12 into flowtricks:main Oct 13, 2026
3 of 4 checks passed
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.

2 participants