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
10 changes: 10 additions & 0 deletions packages/core/src/runtime/adapters/gsap.steps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ describe("gsap adapter on a step", () => {
expect(film.shown()).toEqual([false, true, false]);
});

it.each([undefined, 1, 2.7])(
"shows the first step's frame when seeking to 0 from %s s",
(from) => {
const film = steppedFilm();
if (from !== undefined) film.timeline.totalTime(from, true);
film.adapter.seek({ time: 0 });
expect(film.shown()).toEqual([true, false, false]);
},
);

it("fires a call on the step once when seeking onto it twice", () => {
const film = steppedFilm();
film.adapter.seek({ time: 2.5 });
Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/runtime/adapters/gsap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ 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 && structure) reapplyStepsInAuthoredOrder(timeline, structure, t);
if (!below) reapplyStepsInAuthoredOrder(timeline, structure ?? ownStructureOf(children), t);
}

function ownStructureOf(children: unknown[]): GsapStructureKey | undefined {
const owner = (children[0] as GsapPlaced | undefined)?.parent;
return owner ? { owner, version: "" } : undefined;
}

function reapplyStepsInAuthoredOrder(
timeline: { getChildren?: RuntimeTimelineLike["getChildren"] },
structure: GsapStructureKey,
structure: GsapStructureKey | undefined,
t: number,
): void {
if (!structure) return;
for (const step of stepsAt(timeline, structure, t)) {
const { ratio, _zTime, _act } = step;
step.render(0, true, true);
Expand Down Expand Up @@ -366,7 +372,9 @@ function stepsAt(
structure: GsapStructureKey,
t: number,
): GsapStep[] {
const { points } = placedLandingMarks(timeline, structure);
const { points } = structure.version
? placedLandingMarks(timeline, structure)
: placeLandingMarks(timeline, structure);
const steps: GsapStep[] = [];
for (let i = firstPointFrom(points, t - PLAYHEAD_FLOAT_NOISE); i < points.length; i++) {
if (points[i]!.at > t + PLAYHEAD_FLOAT_NOISE) break;
Expand Down
Loading