MotionScript

@motion-script/core


@motion-script/core / tween

Function: tween()

tween(duration, callback): FrameGenerator

Defined in: tween/tween.ts:18

Core animation primitive. Runs callback every frame for duration seconds, passing a normalized progress value t in [0, 1].

The callback receives a pre-eased t — apply your easing before calling (typically done by AnimationBuilder / node helpers). The generator guarantees a final call with t = 1 so the end state is always applied cleanly, even if the last frame overshoots.

Parameters

duration

number

Length of the animation in seconds.

callback

(t) => void

Called each frame with the current normalized progress.

Returns

FrameGenerator

Example

yield* tween(0.5, t => { node.opacity = t; });