mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
fix(studio): resume drag-paused timelines instead of only re-seeking (#1876)
Drag start pauses every window.__timelines entry and records the list in data-hf-drag-paused-timelines; resumeGsapTimelines then removed the attribute and only re-seeked the player, never unpausing anything. The main timeline survives (seek-driven every frame) but play-state-driven sub-composition timelines froze permanently after any element drag, and deselecting could not recover them. Now unpauses exactly the recorded ids (never touching timelines the drag did not pause) before the player re-seek. Verified live: after a real drag on an animated element all scene timelines stay unpaused. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
7e3bcd9ef1
commit
64b94ebf3a
@@ -2,6 +2,7 @@ import { Window } from "happy-dom";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
applyManualOffsetDragCommit,
|
||||
resumeGsapTimelines,
|
||||
applyManualOffsetDragDraft,
|
||||
applyManualOffsetDragMatrix,
|
||||
createManualOffsetDragMember,
|
||||
@@ -447,3 +448,51 @@ describe("GSAP-element drag — dot-a flies regressions", () => {
|
||||
expect(element.style.getPropertyValue("transform")).toMatch(/translate\(/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resumeGsapTimelines", () => {
|
||||
it("unpauses exactly the timelines the drag start paused, then re-seeks the player", () => {
|
||||
const window = new Window();
|
||||
const element = window.document.createElement("div");
|
||||
element.setAttribute("data-hf-drag-paused-timelines", "figma-demo-unlock,figma-demo-stagger");
|
||||
window.document.body.append(element);
|
||||
|
||||
const pausedState: Record<string, boolean> = {
|
||||
"figma-demo-unlock": true,
|
||||
"figma-demo-stagger": true,
|
||||
main: true,
|
||||
};
|
||||
const makeTl = (id: string) => ({
|
||||
paused: (value?: boolean) => {
|
||||
if (value !== undefined) pausedState[id] = value;
|
||||
return pausedState[id]!;
|
||||
},
|
||||
});
|
||||
const seeks: number[] = [];
|
||||
const win = element.ownerDocument.defaultView as unknown as {
|
||||
__timelines?: Record<string, unknown>;
|
||||
__player?: { seek: (t: number) => void; getTime: () => number };
|
||||
};
|
||||
win.__timelines = {
|
||||
"figma-demo-unlock": makeTl("figma-demo-unlock"),
|
||||
"figma-demo-stagger": makeTl("figma-demo-stagger"),
|
||||
main: makeTl("main"),
|
||||
};
|
||||
win.__player = { seek: (t: number) => seeks.push(t), getTime: () => 3.5 };
|
||||
|
||||
resumeGsapTimelines(element);
|
||||
|
||||
expect(pausedState["figma-demo-unlock"]).toBe(false);
|
||||
expect(pausedState["figma-demo-stagger"]).toBe(false);
|
||||
// main was NOT paused by the drag — leave its state alone
|
||||
expect(pausedState["main"]).toBe(true);
|
||||
expect(seeks).toEqual([3.5]);
|
||||
expect(element.hasAttribute("data-hf-drag-paused-timelines")).toBe(false);
|
||||
});
|
||||
|
||||
it("is a no-op without the paused-timelines attribute", () => {
|
||||
const window = new Window();
|
||||
const element = window.document.createElement("div");
|
||||
window.document.body.append(element);
|
||||
expect(() => resumeGsapTimelines(element)).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -561,11 +561,23 @@ export function resumeGsapTimelines(element: HTMLElement): void {
|
||||
if (!ids) return;
|
||||
const win = element.ownerDocument.defaultView as
|
||||
| (Window & {
|
||||
__timelines?: Record<string, { pause?: () => void }>;
|
||||
__timelines?: Record<string, { paused?: (value?: boolean) => boolean }>;
|
||||
__player?: { seek?: (t: number) => void; getTime?: () => number };
|
||||
})
|
||||
| null;
|
||||
if (!win) return;
|
||||
// Unpause exactly the timelines the drag start paused. The player seek below
|
||||
// repositions them, but a seek alone leaves play-state-driven sub-composition
|
||||
// timelines paused forever — the "selecting a piece kills its animation" bug:
|
||||
// main survives (seek-driven every frame) while every scene timeline freezes,
|
||||
// and deselecting can't recover because nothing else ever resumes them.
|
||||
for (const id of ids.split(",")) {
|
||||
try {
|
||||
win.__timelines?.[id]?.paused?.(false);
|
||||
} catch {
|
||||
/* cross-origin guard */
|
||||
}
|
||||
}
|
||||
const t = win.__player?.getTime?.() ?? 0;
|
||||
win.__player?.seek?.(t);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user