Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/core/src/runtime/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2897,6 +2897,29 @@ describe("initSandboxRuntimeModular", () => {
expect(seekCalls).toEqual([{ time: 2, suppressEvents: false }]);
});

it("fires a call added after the first seek exactly once", () => {
const root = document.createElement("div");
root.setAttribute("data-composition-id", "main");
root.setAttribute("data-root", "true");
root.setAttribute("data-start", "0");
root.setAttribute("data-duration", "10");
root.setAttribute("data-width", "1920");
root.setAttribute("data-height", "1080");
document.body.appendChild(root);

const main = gsap.timeline({ paused: true }).to({ x: 0 }, { x: 1, duration: 10 });
window.__timelines = { main };
initSandboxRuntimeModular();
window.__player?.renderSeek(1);

const fired = vi.fn();
main.call(fired, [], 2);
window.__player?.renderSeek(2);
window.__player?.renderSeek(3);

expect(fired).toHaveBeenCalledTimes(1);
});

it("shows pip video at global start time even when host composition starts late", () => {
// Regression: resolveStartForElement used to add the host composition's start on top of
// the video's own data-start, causing double-offset. A pip video with data-start="45.40"
Expand Down
17 changes: 2 additions & 15 deletions packages/core/src/runtime/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4249,7 +4249,6 @@ export function initSandboxRuntimeModular(): void {
const isObjectRecord = (value: unknown): value is Record<string, unknown> =>
typeof value === "object" && value !== null;

const gsapCallbackTweenCache = new WeakMap<RuntimeTimelineLike, boolean>();
const GSAP_CALLBACK_NAMES = [
"onStart",
"onUpdate",
Expand All @@ -4271,9 +4270,6 @@ export function initSandboxRuntimeModular(): void {
};

const hasZeroDurationCallbackTween = (timeline: RuntimeTimelineLike): boolean => {
const cached = gsapCallbackTweenCache.get(timeline);
if (cached != null) return cached;

if (!("getChildren" in timeline) || typeof timeline.getChildren !== "function") {
return false;
}
Expand All @@ -4283,13 +4279,9 @@ export function initSandboxRuntimeModular(): void {
children = timeline.getChildren(true, true, true);
} catch (err) {
swallow("runtime.init.gsapCallbackChildren", err);
gsapCallbackTweenCache.set(timeline, false);
return false;
}
if (!Array.isArray(children)) {
gsapCallbackTweenCache.set(timeline, false);
return false;
}
if (!Array.isArray(children)) return false;

for (const child of children) {
if (!isObjectRecord(child)) continue;
Expand All @@ -4300,13 +4292,8 @@ export function initSandboxRuntimeModular(): void {

const totalDuration = readGsapDuration(child, "totalDuration");
const duration = totalDuration ?? readGsapDuration(child, "duration");
if (duration != null && duration <= 0.000001) {
gsapCallbackTweenCache.set(timeline, true);
return true;
}
if (duration != null && duration <= 0.000001) return true;
}

gsapCallbackTweenCache.set(timeline, false);
return false;
};

Expand Down
Loading