fix(core): a sealed recording starts on a composition without GSAP (#8593)

This commit is contained in:
Miguel Ángel
2026-11-23 15:16:26 +00:00
committed by GitHub
parent 574b5e3d3b
commit bc33d032e5
2 changed files with 11 additions and 3 deletions
@@ -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();
});
});
@@ -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;