androidx.compose.animation.core
FloatAnimationSpec
Interface · from org.jetbrains.compose.animation:animation-core:1.12.2
No hand-written docs yet.
FloatAnimationSpec interface is similar to VectorizedAnimationSpec, except it deals exclusively with floats.
interface FloatAnimationSpec : AnimationSpec<Float>
Is a
Functions
getValueFromNanos
fun getValueFromNanos(
playTimeNanos: Long,
initialValue: Float,
targetValue: Float,
initialVelocity: Float,
): Float
Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.
getVelocityFromNanos
fun getVelocityFromNanos(
playTimeNanos: Long,
initialValue: Float,
targetValue: Float,
initialVelocity: Float,
): Float
Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.
getEndVelocity
fun getEndVelocity(
initialValue: Float,
targetValue: Float,
initialVelocity: Float,
): Float
Calculates the end velocity of the animation with the provided start/end values, and start velocity. For duration-based animations, end velocity will be the velocity of the animation at the duration time. This is also the default assumption. However, for spring animations, the transient trailing velocity will be snapped to zero.
getDurationNanos
fun getDurationNanos(
initialValue: Float,
targetValue: Float,
initialVelocity: Float,
): Long
Calculates the duration of an animation. For duration-based animations, this will return the pre-defined duration. For physics-based animations, the duration will be estimated based on the physics configuration (such as spring stiffness, damping ratio, visibility threshold) as well as the initialValue, targetValue values, and initialVelocity.
Library docs
FloatAnimationSpec interface is similar to VectorizedAnimationSpec, except it deals
exclusively with floats.
Like VectorizedAnimationSpec, FloatAnimationSpec is entirely stateless as well. It requires
start/end values and start velocity to be passed in for the query of velocity and value of the
animation. The FloatAnimationSpec itself stores only the animation configuration (such as the
delay, duration and easing curve for FloatTweenSpec, or spring constants for FloatSpringSpec.
A FloatAnimationSpec can be converted to an VectorizedAnimationSpec using vectorize.