FloatDecayAnimationSpec

Known direct subclasses
FloatExponentialDecaySpec

This is a decay animation where the friction/deceleration is always proportional to the velocity.

SplineBasedFloatDecayAnimationSpec

A native Android fling curve decay.


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.

Summary

Public functions

Long
getDurationNanos(initialValue: Float, initialVelocity: Float)

Returns the duration of the decay animation, in nanoseconds.

Cmn
Float
getTargetValue(initialValue: Float, initialVelocity: Float)

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

Cmn
Float
getValueFromNanos(
    playTimeNanos: Long,
    initialValue: Float,
    initialVelocity: Float
)

Returns the value of the animation at the given time.

Cmn
Float
getVelocityFromNanos(
    playTimeNanos: Long,
    initialValue: Float,
    initialVelocity: Float
)

Returns the velocity of the animation at the given time.

Cmn

Public properties

Float

This is the absolute value of a velocity threshold, below which the animation is considered finished.

Cmn

Extension functions

DecayAnimationSpec<T>

Creates a DecayAnimationSpec from a FloatDecayAnimationSpec by applying the given FloatDecayAnimationSpec on every dimension of the AnimationVector that T converts to.

Cmn

Public functions

getDurationNanos

fun getDurationNanos(initialValue: Float, initialVelocity: Float): Long

Returns the duration of the decay animation, in nanoseconds.

Parameters
initialValue: Float

start value of the animation

initialVelocity: Float

start velocity of the animation

getTargetValue

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
initialValue: Float

The start value of the animation

initialVelocity: Float

The start velocity of the animation

getValueFromNanos

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

Returns the value of the animation at the given time.

Parameters
playTimeNanos: Long

The time elapsed in milliseconds since the start of the animation

initialValue: Float

The start value of the animation

initialVelocity: Float

The start velocity of the animation

getVelocityFromNanos

fun getVelocityFromNanos(
    playTimeNanos: Long,
    initialValue: Float,
    initialVelocity: Float
): Float

Returns the velocity of the animation at the given time.

Parameters
playTimeNanos: Long

The time elapsed in milliseconds since the start of the animation

initialValue: Float

The start value of the animation

initialVelocity: Float

The start velocity of the animation

Public properties

absVelocityThreshold

val absVelocityThresholdFloat

This is the absolute value of a velocity threshold, below which the animation is considered finished.

Extension functions

generateDecayAnimationSpec

fun <T : Any?> FloatDecayAnimationSpec.generateDecayAnimationSpec(): DecayAnimationSpec<T>

Creates a DecayAnimationSpec from a FloatDecayAnimationSpec by applying the given FloatDecayAnimationSpec on every dimension of the AnimationVector that T converts to.