Skip to content

fix(core): a sealed resize keeps a layer centred by a % translate under the pointer - #8547

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/sealed-resize-centre-probe
Nov 23, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/sealed-resize-centre-probe

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What

In a sealed preview, resizing a layer centred by a CSS translate percentage (left: 50%; top: 50%; translate: -50% -50%) keeps it under the pointer again. Since #8467 the box drifted about 60 px from the pointer while it was dragged. An unsealed preview was never affected.

Why

A sealed resize draws the new size in the frame and pins the layer with a translate. To work out that translate, #8467 made the frame measure, at gesture start, how far the layer's centre moves as its drawn size grows. The probe grew the box with its translate still written as percentages, so a translate: -50% layer re-centred itself and measured 0, and Studio pinned it by 0.

The draft doesn't draw it that way. Once it draws a translate, drawTranslate (packages/core/src/runtime/editingDraft.ts) replaces the layer's translate with its computed value, each % as the px it was when the gesture started. From then on the layer grows from its corner and its centre moves half the growth, and nothing took that back: the box drifted half the resize away from the pointer.

Layers centred by GSAP xPercent / yPercent, the case #8467 fixed, are drawn through transform, which the draft leaves alone, so they keep measuring 0.

Related work

Fixes the regression from #8467.

How

measureGrowResponse (packages/core/src/runtime/editingGestureStart.ts) now writes the translate the resize draft will draw (movedTranslate(computedTranslateAxes(element), 0), the same helpers drawTranslate uses) before each probe size, and puts the layer's own translate back with its size afterwards.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

fails without the fix: packages/core/src/runtime/editingGestureStart.test.ts, "measures a %-translated box's growth as the draft draws it, its % turned into px". On main the probe reports 0 for a translate: -50% -50% card whose box grows from its corner once the % is px.

With the fix, on a Linux machine: that file and editingDraft.test.ts pass three runs in a row (28 tests).

Bench

Edit-accuracy bench on a Linux machine, main at the merge of #8301 (513dcce) with and without this change, the same bench for both. Live tracking is the worst px between the box and the pointer while dragging; every drop was 0.0.

case sealed, main sealed, this change unsealed, main unsealed, this change
seqresize-none-center (CSS translate: -50%), root 60.43 0.28 0.05 0.05
seqresize-none-center, nested 60.43 0.23 0.05 0.05
resize-hold-xpercent (GSAP xPercent, #8467's case), root and nested 0.27 0.27 0.04 0.04
resize-tween-xpercent, root and nested 0.27 0.27 0.06 0.06

The commit before #8467 (2d72e52) tracks seqresize-none-center at 0.28 sealed, and #8467 at 60.43: a bisect with this bench at every step.

The 0.2 px left between sealed and unsealed is while dragging only; both drop at 0.0.

No visible change

Sealed previews are off by default, so nothing changes for anyone yet. With them on, a resized layer centred by a CSS translate % stays under the pointer.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 60 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The growth probe now measures with the same pixel-resolved translate the sealed resize draft draws. It restores the original inline values and priorities after measuring, and leaves the transforms used by GSAP alone. All 28 focused tests passed with a local test-only alias for the workspace parser. Restoring the previous gesture code made the named regression fail on the expected growth coefficients.

— tai (automated review)

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit effc958 Nov 23, 2026
147 of 148 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-resize-centre-probe branch November 23, 2026 00:58
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