AnimatedProperty

class AnimatedProperty<T>(startValue: T, targetValue: T, spec: AnimationSpec, interpolate: (start: T, target: T, fraction: Float) -> T) : Animatable

A value that animates from startValue to targetValue over AnimationSpec.durationMs, following AnimationSpec.easing and AnimationSpec.repeatMode. interpolate is supplied by the caller because "what's halfway between two values" depends entirely on what T is (a plain number, a color, a position, ...) — this class only owns the timing/easing/repeat math, not the interpolation itself.

Constructors

Link copied to clipboard
constructor(startValue: T, targetValue: T, spec: AnimationSpec, interpolate: (start: T, target: T, fraction: Float) -> T)

Properties

Link copied to clipboard

Whether it has reached its end (only an animation that plays once ends; a repeating one never finishes).

Link copied to clipboard
var value: T

Where it is now: the start value before the first tick, the interpolated value after each one, and the target once it has finished.

Functions

Link copied to clipboard
open override fun onTick(deltaMs: Long)

Advances by deltaMs milliseconds, the time since the previous call.