API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classTween

@codexo/exojs / animation / stable

Animates numeric properties of `target` from their current value to a configured end value over a duration in seconds. Supports easing, delay, repeat (with optional yoyo), chaining, and lifecycle callbacks (Tween.onStart, Tween.onUpdate, Tween.onComplete, Tween.onRepeat). Tweens are typically created via TweenSystem.create, which binds them to that system; Tween.start then enters them into its update loop so they advance once per frame. Stand-alone usage is supported by calling Tween.update manually with a frame delta. Start values are captured lazily on the first update after Tween.start, so target properties may be mutated between configuration and start without affecting the captured baseline. Only number-typed properties on `target` are interpolated; non-number properties listed in Tween.to emit a console warning and are skipped.

3
props
15
methods
0
events
Import
import { Tween } from '@codexo/exojs'

Animates numeric properties of `target` from their current value to a configured end value over a duration in seconds. Supports easing, delay, repeat (with optional yoyo), chaining, and lifecycle callbacks (Tween.onStart, Tween.onUpdate, Tween.onComplete, Tween.onRepeat).

Tweens are typically created via TweenSystem.create, which binds them to that system; Tween.start then enters them into its update loop so they advance once per frame. Stand-alone usage is supported by calling Tween.update manually with a frame delta.

Start values are captured lazily on the first update after Tween.start, so target properties may be mutated between configuration and start without affecting the captured baseline.

Only number-typed properties on `target` are interpolated; non-number properties listed in Tween.to emit a console warning and are skipped.

Constructors1
new(target: T): Tween<T>
Methods15
chain(next: Tween): Tween
When this tween completes naturally, automatically start next. Returns next for fluent chaining: fadeIn.chain(moveOut).start() - note that start() here starts moveOut, so typically you only call start() on the first tween.
delay(seconds: number): this
Delay in seconds before the tween begins interpolating. Default 0.
easing(easingFunction: EasingFunction): this
Easing function applied to the normalized time. Default Ease.linear.
Register a callback fired when the tween finishes naturally (all repeat cycles exhausted). Does NOT fire when the tween is stopped via Tween.stop.
Register a callback fired at the boundary of each repeat cycle, after the cycle counter is decremented and before the next cycle begins. Not fired on the final cycle's completion (use Tween.onComplete for that).
Register a callback fired once when the tween begins interpolating (after any configured delay has elapsed). Fires only on the first cycle - repeats do not re-trigger it.
Register a callback fired on every active update. Receives the eased progress in 0..1 - already direction-flipped for yoyo cycles.
pause(): this
Pause the tween. update() calls are ignored while paused.
repeat(count: number): this
Number of additional repeat cycles. -1 = infinite. Default 0 (runs once). The argument counts cycles **after** the first, not the total cycle count - repeat(2) runs the animation three times total (the initial pass plus two repeats).
resume(): this
Resume a paused tween from where it left off.
start(): this
Start or restart the tween. Resets all elapsed time, the start-value snapshot, playback direction, and repeat counter. Registers the tween with its system, if one is assigned - both for the first start and after an eviction caused by natural completion or Tween.stop, so it (re)starts receiving frame updates either way. Stand-alone tweens (no system) are unaffected.
stop(): this
Stop the tween without finishing. Target properties stay at their current interpolated values. onComplete does NOT fire. The tween is removed from its system if one is assigned - unconditionally rather than state-gated, which for anything the system does not hold (an idle or already-finished tween) is simply a no-op. The system binding itself survives, so a later Tween.start re-enters the update list.
to(properties: Partial<Record<NumericKeys<T>, number>>, duration: number): this
Set target end-values and duration in seconds. Replaces any prior to(). The starting values are captured lazily on first update() after start(), so mutating target between to() and start() is safe. Only numeric properties of target are accepted. Non-numeric keys are rejected at compile time; the runtime guard in update() remains as a safety net for untyped callers.
update(deltaSeconds: number): void
Advance the tween by deltaSeconds. Called by TweenSystem each frame, or manually for stand-alone usage. No-ops when Paused, Stopped, or Complete.
yoyo(enabled: boolean): this
Reverse playback direction on each repeat cycle. Only meaningful when combined with repeat(). Calling yoyo() without repeat() is a no-op.
Properties3
progress: number
Current eased progress in 0..1. Reflects the eased t after applying the easing function, not the raw elapsed/duration ratio. Returns 0 while the tween is in the delay phase (state is Active but the configured delay has not yet elapsed).
target: T
Source