MotionScript

@motion-script/core


@motion-script/core / FrameGenerator

Type Alias: FrameGenerator

FrameGenerator = Generator<void, void, number>

Defined in: tween/generator.ts:21

A generator that drives a single animation forward frame by frame.

  • yield suspends the animation and receives the elapsed delta time (dt, in seconds) for that frame when execution resumes.
  • return (or falling off the end) signals completion.

Compose frame generators with sequence and parallel, or drive them manually by calling .next(dt) until .done is true.

Example

function* fadeIn(node: MyNode): FrameGenerator {
  let elapsed = 0;
  while (elapsed < 1) {
    node.opacity = elapsed;
    elapsed += yield;
  }
  node.opacity = 1;
}