public class DecayAnimation<T, V : AnimationVector> /*@VisibleForTesting*/
constructor(
private val animationSpec: VectorizedDecayAnimationSpec<V>,
override val typeConverter: TwoWayConverter<T, V>,
public val initialValue: T,
initialVelocityVector: V,
) : Animation<T, V>
DecayAnimation is an animation that slows down from initialVelocityVector as time goes on. DecayAnimation is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, DecayAnimation stores all the animation related information: initialValue, initialVelocityVector, decay animation spec, typeConverter.
Note: Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top DecayAnimation, such as Animatable.animateDecay, AnimationState.animateDecay, etc.
Secondary Constructors
public constructor(
animationSpec: DecayAnimationSpec<T>,
typeConverter: TwoWayConverter<T, V>,
initialValue: T,
initialVelocityVector: V,
) : this(
animationSpec.vectorize(typeConverter),
typeConverter,
initialValue,
initialVelocityVector,
)
DecayAnimation is an animation that slows down from initialVelocityVector as time goes on. DecayAnimation is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, DecayAnimation stores all the animation related information: initialValue, initialVelocityVector, decay animation spec, typeConverter.
Note: Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top DecayAnimation, such as Animatable.animateDecay, AnimationState.animateDecay, etc.
Parameters
| animationSpec | Decay animation spec that defines the slow-down curve of the animation |
| typeConverter | Type converter to convert the type T from and to AnimationVector |
| initialValue | The starting value of the animation |
| initialVelocityVector | The starting velocity of the animation in AnimationVector form |
public constructor(
animationSpec: DecayAnimationSpec<T>,
typeConverter: TwoWayConverter<T, V>,
initialValue: T,
initialVelocity: T,
) : this(
animationSpec.vectorize(typeConverter),
typeConverter,
initialValue,
typeConverter.convertToVector(initialVelocity),
)
DecayAnimation is an animation that slows down from initialVelocity as time goes on. DecayAnimation is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, DecayAnimation stores all the animation related information: initialValue, initialVelocity, animationSpec, typeConverter.
Note: Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top DecayAnimation, such as Animatable.animateDecay, AnimationState.animateDecay, etc.
Parameters
| animationSpec | Decay animation spec that defines the slow-down curve of the animation |
| typeConverter | Type converter to convert the type T from and to AnimationVector |
| initialValue | The starting value of the animation |
| initialVelocity | The starting velocity of the animation |