AnimatedValue

class AnimatedValue<T> : Value<T>

A mutable, animation-aware value holder that implements Value for direct use in Litho Style APIs.

AnimatedValue integrates with Litho's state read tracking for automatic phase-skipping: when a component reads value during bind (e.g., Style.alpha(animatedFloat)), only the bind phase runs on animation updates — layout and resolve are skipped.

Value Ownership

Unlike State, the animated value is stored directly in this instance rather than in the component state container. State updates use a no-op HookUpdater — they serve purely as re-render signals. The actual value is read from _currentValue when the component re-evaluates.

Animation Lifecycle

  • retarget: Starts an animation toward a target value. If an animation is already running, it is interrupted with velocity preservation for smooth retargeting. The caller is responsible for registering this value with an AnimationController for frame callbacks.

  • snapTo: Immediately sets the value without animation and triggers a re-render.

  • restart: Restarts an animation from an explicit initial value, published on the next frame.

  • stop: Stops the current animation at its present value.

Frame Updates

Values are updated each frame via onFrame calls from the AnimationController. This class has no direct dependency on the frame loop — registration is the caller's responsibility.

Parameters

T

The type of the animated value.

See also

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

True if an animation is actively running: has an animator AND is receiving frames.

Link copied to clipboard
Link copied to clipboard

The state ID used for read tracking and re-render signaling.

Link copied to clipboard

The type converter used for float-space animation computation.

Link copied to clipboard
open override val value: T

The current animated value.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun retarget(target: T, spec: AnimationSpec<T>)

Starts an animation toward target using the given spec.

Link copied to clipboard
fun snapTo(target: T, notify: Boolean = true)

Immediately sets the value to target without animation.

Link copied to clipboard

Stops the current animation at its present value.

Link copied to clipboard
open override fun toString(): String