Source set: Common
public class FloatExponentialDecaySpec(
@FloatRange(from = 0.0, fromInclusive = false) frictionMultiplier: Float = 1f,
@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. |
Properties
absVelocityThreshold
Source set: Common
override val absVelocityThreshold: Float = max(0.0000001f, abs(absVelocityThreshold))
Functions
getValueFromNanos
Source set: Common
override fun getValueFromNanos(
playTimeNanos: Long,
initialValue: Float,
initialVelocity: Float,
): Float
getVelocityFromNanos
Source set: Common
override fun getVelocityFromNanos(
playTimeNanos: Long,
initialValue: Float,
initialVelocity: Float,
): Float
getDurationNanos
Source set: Common
override fun getDurationNanos(initialValue: Float, initialVelocity: Float): Long
getTargetValue
Source set: Common
override fun getTargetValue(initialValue: Float, initialVelocity: Float): Float