fix(studio): a sealed resize saves its anchor on the route GSAP moves it by (#8193)

* fix(studio): a sealed resize saves its anchor on the route GSAP moves it by

* style(studio): format the sealed resize test and drop the new comment lines
This commit is contained in:
Miguel Ángel
2026-11-18 20:11:21 +00:00
committed by GitHub
parent 855ad35c22
commit f149d76ed6
2 changed files with 27 additions and 4 deletions
@@ -15,6 +15,7 @@ import { startGesture } from "./domEditOverlayStartGesture";
import {
applyManualOffsetDragCommit,
applyManualOffsetDragDraft,
createManualOffsetDragMember,
endManualOffsetDragMembers,
} from "./manualOffsetDrag";
import { measurePreviewGestureStart } from "./previewGestureStartRead";
@@ -245,3 +246,26 @@ it("still saves a layer GSAP only holds when the sealed preview's tweens can't b
properties: { x: 120, y: 40 },
});
});
// fails without the fix: the resize read the stand-in's own (empty) timelines, called the layer plain CSS and
// saved its rotated corner's anchor as a raw `translate` that a reload added on top of GSAP's x.
it("a resize in a sealed preview keeps the anchor of a layer its tween moves on GSAP's route", async () => {
mount(SCRIPT);
const iframe = opaqueFrame();
const handle = (await queryPreviewElements(iframe, "#box"))!.matches[0]!.handle;
const standIn = standInFor(iframe, (await describePreviewElements(iframe, [handle]))![0]!);
const overlay = sized(document.createElement("div"), [20, 10, 1200, 800]);
const { rect, start } = (await measurePreviewGestureStart(iframe, overlay, [handle]))!
.elements[0]!;
const result = createManualOffsetDragMember({
key: "box",
selection: { ...makeSelection("box", standIn), id: "box", handle },
element: standIn,
rect,
gesture: "resize",
start,
});
expect(start.gsap).toEqual({ x: 100, y: 40, moving: true });
expect(result.ok && result.member.plainTranslate).toBe(false);
});
@@ -330,10 +330,9 @@ export function createManualOffsetDragMember(input: {
start?: PreviewGestureStart;
}): ManualOffsetDragMemberResult {
const { start, gesture } = input;
const plainTranslate =
start && gesture !== "resize"
? !start.gsap
: !!gesture && editsPlainCss(input.element, gesture === "resize" ? "resize" : "move");
const plainTranslate = start
? !start.gsap
: !!gesture && editsPlainCss(input.element, gesture === "resize" ? "resize" : "move");
// The APPLIED offset, never a dormant var, so a stale one can't fling the element off-screen.
const initialOffset = plainTranslate
? readTranslatePx(input.element)