ExponentialDecay

class ExponentialDecay : DecayAnimation
kotlin.Any
   ↳ androidx.animation.ExponentialDecay

This is a decay animation where the friction/deceleration is always proportional to the velocity. As a result, the velocity goes under an exponential decay. The constructor parameter, friction multiplier, can be tuned to adjust the amount of friction applied in the decay. The higher the multiplier, the higher the friction, the sooner the animation will stop, and the shorter distance the animation will travel with the same starting condition.

Summary

Public constructors

<init>(frictionMultiplier: Float = 1f, absVelocityThreshold: Float = 0.1f)

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

Public methods

Float
getTarget(start: Float, startVelocity: Float)

Returns the target value of the animation based on the starting condition of the animation ( i.

Float
getValue(playTime: Long, start: Float, startVelocity: Float)

Returns the value of the animation at the given time.

Float
getVelocity(playTime: Long, start: Float, startVelocity: Float)

Returns the velocity of the animation at the given time.

Boolean
isFinished(playTime: Long, start: Float, startVelocity: Float)

Returns whether the animation is finished at the given time.

Properties

Float

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

Public constructors

<init>

ExponentialDecay(
    frictionMultiplier: Float = 1f,
    absVelocityThreshold: Float = 0.1f)

This is a decay animation where the friction/deceleration is always proportional to the velocity. As a result, the velocity goes under an exponential decay. The constructor parameter, friction multiplier, can be tuned to adjust the amount of friction applied in the decay. The higher the multiplier, the higher the friction, the sooner the animation will stop, and the shorter distance the animation will travel with the same starting condition.

Public methods

getTarget

fun getTarget(
    start: Float,
    startVelocity: 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
start: Float The start value of the animation
startVelocity: Float The start velocity of the animation

getValue

fun getValue(
    playTime: Long,
    start: Float,
    startVelocity: Float
): Float

Returns the value of the animation at the given time.

Parameters
playTime: Long The time elapsed in milliseconds since the start of the animation
start: Float The start value of the animation
startVelocity: Float The start velocity of the animation

getVelocity

fun getVelocity(
    playTime: Long,
    start: Float,
    startVelocity: Float
): Float

Returns the velocity of the animation at the given time.

Parameters
playTime: Long The time elapsed in milliseconds since the start of the animation
start: Float The start value of the animation
startVelocity: Float The start velocity of the animation

isFinished

fun isFinished(
    playTime: Long,
    start: Float,
    startVelocity: Float
): Boolean

Returns whether the animation is finished at the given time.

Parameters
playTime: Long The time elapsed in milliseconds since the start of the animation
start: Float The start value of the animation
startVelocity: Float The start velocity of the animation

Properties

absVelocityThreshold

val absVelocityThreshold: Float

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