FloatDecayAnimationSpec

Interface

Common
public interface FloatDecayAnimationSpec

This animation interface is intended to be stateless, just like Animation. But unlike Animation, DecayAnimation does not have an end value defined. The end value is a result of the animation rather than an input.

Functions

public fun getValueFromNanos(
        playTimeNanos: Long,
        initialValue: Float,
        initialVelocity: Float,
    ): Float

Returns the value of the animation at the given time.

Parameters

playTimeNanosThe time elapsed in milliseconds since the start of the animation
initialValueThe start value of the animation
initialVelocityThe start velocity of the animation
public fun getDurationNanos(initialValue: Float, initialVelocity: Float): Long

Returns the duration of the decay animation, in nanoseconds.

Parameters

initialValuestart value of the animation
initialVelocitystart velocity of the animation
public fun getVelocityFromNanos(
        playTimeNanos: Long,
        initialValue: Float,
        initialVelocity: Float,
    ): Float

Returns the velocity of the animation at the given time.

Parameters

playTimeNanosThe time elapsed in milliseconds since the start of the animation
initialValueThe start value of the animation
initialVelocityThe start velocity of the animation
public fun getTargetValue(initialValue: Float, initialVelocity: Float): Float

Returns the target value of the animation based on the starting condition of the animation ( i.e. start value and start velocity).

Parameters

initialValueThe start value of the animation
initialVelocityThe start velocity of the animation