tween
Animates a value from from to to over durationMs, calling onUpdate with the blended
value at each frame, for what CSS cannot animate: canvas drawing, a scroll position, WebGL
uniforms, numbers shown as text.
It runs on frameLoop: onUpdate is called right away with from, then once per
frame, and last with the value at progress 1 (exactly to with the default blending).
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | TweenOptions<T, V> & object | Values, duration, easing, blending, callback and cancellation — see TweenOptions |
Returns
Section titled “Returns”FrameLoop — A Tween, to cancel it or await its end
Examples
Section titled “Examples”Animate what CSS cannot
Section titled “Animate what CSS cannot”onUpdate receives the interpolated value at each frame, here to draw on a canvas.
Cancel a running tween
Section titled “Cancel a running tween”finished resolves with false when cancelled before the end.
Related Types
Section titled “Related Types”FrameLoop
Section titled “FrameLoop”A running frameLoop.
TweenOptions
Section titled “TweenOptions”Options for tween.
Interpolatable
Section titled “Interpolatable”A value interpolate can blend: a number, or arrays and plain objects of them, nested at will (a point, a color, a whole set of style properties).
Interpolated
Section titled “Interpolated”The type of an interpolated value: the shape of the input, with literal numbers widened to
number (interpolate(0, 10, t) is a number, not 0 | 10).
A running tween: the FrameLoop that drives it.
