effect-motion
API Referenceeffect-motionNamespacesSceneFunctions

stagger

function stagger<Eff, ScheduleE, ScheduleR>(effects, schedule): Effect<{

Function: stagger()

function stagger<Eff, ScheduleE, ScheduleR>(effects, schedule): Effect<{
  released: number;
},
  | ScheduleE
  | Eff extends Effect<any, E, any> ? E : never,
  | Runner
  | ScheduleR
| Eff extends Effect<any, any, R> ? R : never>;

Defined in: packages/motion/src/Scene.ts:1512

Start animations one after another WITHOUT waiting for each to finish — the cascade.

Type Parameters

Type ParameterDefault type
Eff extends Effect<any, any, any>-
ScheduleEnever
ScheduleRnever

Parameters

ParameterTypeDescription
effectsEffects<Eff>The animations to release in order.
scheduleSchedule<unknown, void, ScheduleE, ScheduleR>When to release each subsequent one.

Returns

Effect<{ released: number; }, | ScheduleE | Eff extends Effect<any, E, any> ? E : never, | Runner | ScheduleR | Eff extends Effect<any, any, R> ? R : never>

{ released } — how many actually started.

Remarks

The first starts immediately and each next one on the schedule's next emission, so earlier items are still running when later ones begin. That overlap is the entire point, and the difference from chain: use stagger for a ripple across many elements, chain when items must not coincide.

The schedule paces the STARTS here, not the gaps. Resolution waits for every released animation to finish, not merely for the last one to be released — so the whole cascade is complete when this returns.

When the schedule ends before the list does, the remaining effects are skipped.

Example

A row of bars rising in a ripple, each starting 80ms after the last while the earlier ones keep going.

yield* Scene.stagger(
	bars.map((bar) => bar.pipe(Motion.moveTo({ y: 40 }, "600 millis"))),
	Schedule.spaced("80 millis"),
);

On this page