diff --git a/packages/core/src/runtime/editingGestureStart.test.ts b/packages/core/src/runtime/editingGestureStart.test.ts index 9b8ddccff4..a2e7b2790b 100644 --- a/packages/core/src/runtime/editingGestureStart.test.ts +++ b/packages/core/src/runtime/editingGestureStart.test.ts @@ -260,10 +260,17 @@ describe("gestureBase", () => { expect(gestureBase(handleFor(card))).toEqual({ x: 12, y: -4, opacity: 0.5, scale: 1.5 }); }); - it("answers null without GSAP, or for an element this load does not have", () => { + // fails without the fix: a page without GSAP answered null, so a sealed recording refused to start where the + // unsealed recorder starts from x 0, y 0, opacity 1 and scale 1. + it("answers the values at rest on a page without GSAP, as the unsealed recorder starts", () => { const card = turnedCard(""); - expect(gestureBase(handleFor(card))).toBeNull(); + expect(gestureBase(handleFor(card))).toEqual({ x: 0, y: 0, opacity: 1, scale: 1 }); + }); + + it("answers null for an element this load does not have", () => { gsapWith([]); expect(gestureBase("0123456789abcdef:999")).toBeNull(); + Reflect.deleteProperty(window, "gsap"); + expect(gestureBase("0123456789abcdef:999")).toBeNull(); }); }); diff --git a/packages/core/src/runtime/editingGestureStart.ts b/packages/core/src/runtime/editingGestureStart.ts index b96231de63..a57ed364cb 100644 --- a/packages/core/src/runtime/editingGestureStart.ts +++ b/packages/core/src/runtime/editingGestureStart.ts @@ -170,7 +170,8 @@ export type EditingGestureBase = { x: number; y: number; opacity: number; scale: export function gestureBase(handle: EditingElementHandle): EditingGestureBase | null { const element = elementForHandle(handle); const gsap = (window as GsapWindow).gsap; - if (!element || !gsap?.getProperty) return null; + if (!element) return null; + if (!gsap?.getProperty) return { x: 0, y: 0, opacity: 1, scale: 1 }; const read = (property: string) => Number(gsap.getProperty?.(element, property)); const base = { x: read("x"), y: read("y"), opacity: read("opacity"), scale: read("scaleX") }; return Object.values(base).every(Number.isFinite) ? base : null;