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) <noreply@anthropic.com>
This commit is contained in:
Miguel Ángel
2026-03-30 22:22:33 +02:00
co-authored by Claude Sonnet 4.6
parent 4f0cb3f789
commit 3db7870d6d
3 changed files with 2 additions and 29 deletions
@@ -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();
@@ -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.
+2 -2
View File
@@ -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");