diff --git a/packages/core/src/runtime/adapters/gsap.order.test.ts b/packages/core/src/runtime/adapters/gsap.order.test.ts index d15e6510f0..0b34ca3e76 100644 --- a/packages/core/src/runtime/adapters/gsap.order.test.ts +++ b/packages/core/src/runtime/adapters/gsap.order.test.ts @@ -1,6 +1,6 @@ import gsap from "gsap"; import { describe, expect, it } from "vitest"; -import { seekGsapTimeline } from "./gsap"; +import { rerenderGsapTimelineAt, seekGsapTimeline } from "./gsap"; import { producerStandIn } from "./gsapStandIn.test-helpers"; import type { RuntimeTimelineLike } from "../types"; @@ -136,9 +136,45 @@ function panelAt(frames: number[], fps?: number, standIn = false): Map { + const { panel, timeline } = fadeInterruptedBySet(standIn); + const opacity = new Map(); + for (const frame of frames) { + const t = frame / SET_FPS; + if (!seekGsapTimeline(timeline, t, false, undefined, SET_FPS)) { + rerenderGsapTimelineAt( + { + totalTime: timeline.totalTime!.bind(timeline), + totalDuration: timeline.totalDuration?.bind(timeline), + getChildren: timeline.getChildren?.bind(timeline), + }, + t, + ); + } + opacity.set(frame, panel.opacity); + } + return opacity; +} + describe("a render where a set interrupts a running tween", () => { const preview = panelAt(range(0, 90)); + it("keeps the set's value through the runtime's re-render, however frames are shared out", () => { + for (const standIn of [false, true]) { + for (const workers of [1, 2, 3, 4, 6]) { + for (let worker = 0; worker < workers; worker++) { + for (const [frame, opacity] of panelThroughRuntimeSeek( + range(worker, 90, workers), + standIn, + )) { + if (frame >= SET_FPS) expect([workers, frame, opacity]).toEqual([workers, frame, 1]); + } + } + } + } + }); + it("lands every frame where preview does when one worker renders in order", () => { for (const [frame, opacity] of panelAt(range(0, 90), SET_FPS)) { expect([frame, opacity]).toEqual([frame, preview.get(frame)]); diff --git a/packages/core/src/runtime/adapters/gsap.ts b/packages/core/src/runtime/adapters/gsap.ts index 39d74505cc..d9358902d5 100644 --- a/packages/core/src/runtime/adapters/gsap.ts +++ b/packages/core/src/runtime/adapters/gsap.ts @@ -57,7 +57,12 @@ function renderOntoInAuthoredOrder( timeline.totalTime(below ? t - REDRAW_STEP : t + REDRAW_STEP, true); primeTweensStartingAt(children, t, below ? REDRAW_STEP : 0); timeline.totalTime(t, true); - if (!below) reapplyStepsInAuthoredOrder(timeline, structure ?? ownStructureOf(children), t); + const own = structure ?? ownStructureOf(children); + if (!below) { + reapplyStepsInAuthoredOrder(timeline, own, t); + } else if (own) { + settleOverlapsEndedBetween(own.owner as RuntimeTimelineLike, t - REDRAW_STEP, t, own.version); + } } function ownStructureOf(children: unknown[]): GsapStructureKey | undefined {