tweenTo
const tweenTo: <Tag>(to, duration, timing?) => <E, R>(instance) => Effect<Instance<Tag>, E, Runner | R> & <Tag, E, R>(instance, to, duration, timing?)
Variable: tweenTo
const tweenTo: <Tag>(to, duration, timing?) => <E, R>(instance) => Effect<Instance<Tag>, E, Runner | R> & <Tag, E, R>(instance, to, duration, timing?) => Effect<Instance<Tag>, E, Runner | R>;Defined in: packages/motion/src/Motion.ts:275
Interpolate numeric fields of an instance to to over duration,
starting from whatever they currently are.
Remarks
This is the RAW layer: fields are addressed by their schema name, so
tweenTo reaches everything the semantic animators don't cover —
radius, width, height, fontSize, strokeWidth, a Camera's
focalLength. Prefer moveTo / fadeTo where they apply;
they move an entity as a unit, which a per-field tween cannot.
Only the fields named in to are touched; the rest are left alone.
to may also be a function of the current data, for a target computed
at animation start. Colors are interpolable too, mixed through Lab by
default.
The final frame receives exactly to (for any easing with f(1) = 1), so
a chain of tweens never accumulates drift. A field that has no current
value — an optional one never set — is a loud defect rather than a
silent NaN; pass an explicit origin with tween instead.
Param
to
The fields to animate and their target values.
Param
duration
How long, in scene time; rounded to whole frames at the runner's frame rate. A zero duration still takes one frame.
Param
timing
An easing name from Timing.timingFunctions, or your own
(t: number) => number.
Default Value
timing — "linear"
Returns
The instance, so animators chain.
See
tween to specify the starting value explicitly.
Example
Grow a circle's radius, then shrink it back with a different curve.
yield* dot.pipe(
Motion.tweenTo({ radius: 40 }, "600 millis", "easeOutBack"),
Motion.tweenTo({ radius: 4 }, "400 millis", "easeInQuad"),
);