Class

AnimationScope

[AnimationScope] provides all the animation related info specific to an animation run.

Common
public class AnimationScope<T, V : AnimationVector>
internal constructor(
    initialValue: T,
    /** [TwoWayConverter] to convert type [T] from and to [AnimationVector]. */
    public val typeConverter: TwoWayConverter<T, V>,
    initialVelocityVector: V,
    lastFrameTimeNanos: Long,
    /** Target value of the animation. */
    public val targetValue: T,
    /** Start time of the animation in the [System.nanoTime] timebase. */
    @get:Suppress("MethodNameUnits") public val startTimeNanos: Long,
    isRunning: Boolean,
    private val onCancel: () -> Unit,
)

AnimationScope provides all the animation related info specific to an animation run. An AnimationScope will be accessible during an animation.

Functions

cancelAnimation

public fun cancelAnimation()

Cancels the animation that this AnimationScope corresponds to. The scope will not be updated any more after cancelAnimation is called.


toAnimationState

public fun toAnimationState(): AnimationState<T, V>

Creates an AnimationState that populates all the fields in AnimationState from AnimationScope.