🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

TargetBasedAnimation

This is a convenient animation wrapper class that works for all target based animations, i.e.

Source set: Common
public class TargetBasedAnimation<T, V : AnimationVector> internal constructor(
    internal val animationSpec: VectorizedAnimationSpec<V>,
    override val typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    targetValue: T,
    initialVelocityVector: V? = null,
) : Animation<T, V>

This is a convenient animation wrapper class that works for all target based animations, i.e. animations that has a pre-defined end value, unlike decay.

It assumes that the starting value and velocity, as well as ending value do not change throughout the animation, and cache these values. This caching enables much more convenient query for animation value and velocity (where only playtime needs to be passed into the methods).

Note: When interruptions happen to the TargetBasedAnimation, a new instance should be created that use the current value and velocity as the starting conditions. This type of interruption handling is the default behavior for both Animatable and Transition. Consider using those APIs for the interruption handling, as well as built-in animation lifecycle management.

Parameters

animationSpec the VectorizedAnimationSpec that will be used to calculate value/velocity
initialValue the start value of the animation
targetValue the end value of the animation
typeConverter the TwoWayConverter that is used to convert animation type T from/to V
initialVelocityVector the start velocity of the animation in the form of AnimationVector

Properties

initialValue

Source set: Common
public val initialValue: T

targetValue

Source set: Common
override val targetValue: T

isInfinite

Source set: Common
override val isInfinite: Boolean

durationNanos

Source set: Common
override val durationNanos: Long

Functions

getValueFromNanos

Source set: Common
override fun getValueFromNanos(playTimeNanos: Long): T

getVelocityVectorFromNanos

Source set: Common
override fun getVelocityVectorFromNanos(playTimeNanos: Long): V

toString

Source set: Common
override fun toString(): String