From 3db7870d6ded6c169b7b2eb4b1160759d3a8559d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Mon, 30 Mar 2026 17:51:13 +0200 Subject: [PATCH] fix(runtime): fix Lottie adapter conflicting with GSAP-driven animations Two issues caused GSAP-controlled Lottie animations to display at the wrong frame or not at all: 1. Adapter order: Lottie ran after GSAP, overriding the correct frame from GSAP's onUpdate with wrong absolute-time ms. Fix: move Lottie before GSAP so GSAP's onUpdate fires last and wins. 2. play() conflict: adapter called anim.play() causing Lottie to advance independently, fighting GSAP's goToAndStop scrubbing. Fix: remove play() from the Lottie adapter (it is optional). Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../core/src/runtime/adapters/lottie.test.ts | 10 ---------- packages/core/src/runtime/adapters/lottie.ts | 17 ----------------- packages/core/src/runtime/init.ts | 4 ++-- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/packages/core/src/runtime/adapters/lottie.test.ts b/packages/core/src/runtime/adapters/lottie.test.ts index 11fadb2ba6..a8e5eb4a53 100644 --- a/packages/core/src/runtime/adapters/lottie.test.ts +++ b/packages/core/src/runtime/adapters/lottie.test.ts @@ -141,16 +141,6 @@ describe("lottie adapter", () => { }); }); - describe("play", () => { - it("plays lottie-web animation", () => { - const anim = createLottieWebAnim(); - lottieWindow.__hfLottie = [anim]; - const adapter = createLottieAdapter(); - adapter.play!(); - expect(anim.play).toHaveBeenCalled(); - }); - }); - describe("revert", () => { it("does not throw", () => { const adapter = createLottieAdapter(); diff --git a/packages/core/src/runtime/adapters/lottie.ts b/packages/core/src/runtime/adapters/lottie.ts index cbfb4e2c96..9860192bf1 100644 --- a/packages/core/src/runtime/adapters/lottie.ts +++ b/packages/core/src/runtime/adapters/lottie.ts @@ -129,23 +129,6 @@ export function createLottieAdapter(): RuntimeDeterministicAdapter { } }, - play: () => { - const instances = (window as LottieWindow).__hfLottie; - if (!instances || instances.length === 0) return; - - for (const anim of instances) { - try { - if (isLottieWebAnimation(anim)) { - anim.play(); - } else if (isDotLottiePlayer(anim)) { - anim.play(); - } - } catch { - // ignore - } - } - }, - revert: () => { // Don't clear __hfLottie — the animation objects are owned by the composition. // Just let them be garbage collected naturally. diff --git a/packages/core/src/runtime/init.ts b/packages/core/src/runtime/init.ts index 278553e7f2..97b19296e8 100644 --- a/packages/core/src/runtime/init.ts +++ b/packages/core/src/runtime/init.ts @@ -1389,9 +1389,9 @@ export function initSandboxRuntimeModular(): void { resolveStartSeconds: (element) => resolveStartForElement(element, 0), }), createWaapiAdapter(), - createGsapAdapter({ getTimeline: () => state.capturedTimeline }), - createThreeAdapter(), createLottieAdapter(), + createThreeAdapter(), + createGsapAdapter({ getTimeline: () => state.capturedTimeline }), ] as RuntimeDeterministicAdapter[]; installRuntimeErrorDiagnostics(); runAdapters("discover");