FloatExponentialDecaySpec

class FloatExponentialDecaySpec(@FloatRange(from = 0.0, fromInclusive = false) frictionMultiplier: Float = 1.0f, @FloatRange(from = 0.0, fromInclusive = false) absVelocityThreshold: Float = 0.1f) : FloatDecayAnimationSpec

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, frictionMultiplier, 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.

Parameters

frictionMultiplier

The friction multiplier, indicating how quickly the animation should stop. This should be greater than 0, with a default value of 1.0.

absVelocityThreshold

The speed at which the animation is considered close enough to rest for the animation to finish.

Constructors

Link copied to clipboard
constructor(@FloatRange(from = 0.0, fromInclusive = false) frictionMultiplier: Float = 1.0f, @FloatRange(from = 0.0, fromInclusive = false) absVelocityThreshold: Float = 0.1f)

Properties

Link copied to clipboard
open override val absVelocityThreshold: Float

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

Functions

Link copied to clipboard
open override fun getDurationNanos(initialValue: Float, initialVelocity: Float): Long

Returns the duration of the decay animation, in nanoseconds.

Link copied to clipboard
open override 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).

Link copied to clipboard
open override fun getValueFromNanos(playTimeNanos: Long, initialValue: Float, initialVelocity: Float): Float

Returns the value of the animation at the given time.

Link copied to clipboard
open override fun getVelocityFromNanos(playTimeNanos: Long, initialValue: Float, initialVelocity: Float): Float

Returns the velocity of the animation at the given time.