FloatTweenSpec


FloatTweenSpec animates a Float value from any start value to any end value using a provided easing function. The animation will finish within the duration time. Unless a delay is specified, the animation will start right away.

Summary

Public constructors

FloatTweenSpec(duration: Int, delay: Int, easing: Easing)
Cmn

Public functions

open Long
getDurationNanos(
    initialValue: Float,
    targetValue: Float,
    initialVelocity: Float
)

Calculates the duration of an animation.

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

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

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

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

Cmn

Public properties

Int

the amount of time the animation will wait before it starts running.

Cmn
Int

the amount of time (in milliseconds) the animation will take to finish.

Cmn

Inherited functions

From androidx.compose.animation.core.FloatAnimationSpec
open Float
getEndVelocity(
    initialValue: Float,
    targetValue: Float,
    initialVelocity: Float
)

Calculates the end velocity of the animation with the provided start/end values, and start velocity.

Cmn
open VectorizedFloatAnimationSpec<V>

Create an VectorizedAnimationSpec that animates AnimationVector from a FloatAnimationSpec.

Cmn

Public constructors

FloatTweenSpec

FloatTweenSpec(
    duration: Int = DefaultDurationMillis,
    delay: Int = 0,
    easing: Easing = FastOutSlowInEasing
)
Parameters
duration: Int = DefaultDurationMillis

the amount of time (in milliseconds) the animation will take to finish. Defaults to DefaultDurationMillis

delay: Int = 0

the amount of time the animation will wait before it starts running. Defaults to 0.

easing: Easing = FastOutSlowInEasing

the easing function that will be used to interoplate between the start and end value of the animation. Defaults to FastOutSlowInEasing.

Public functions

getDurationNanos

open 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.

Note: this may be a computation that is expensive - especially with spring based animations

Parameters
initialValue: Float

start value of the animation

targetValue: Float

end value of the animation

initialVelocity: Float

start velocity of the animation

getValueFromNanos

open 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.

Parameters
playTimeNanos: Long

time since the start of the animation

initialValue: Float

start value of the animation

targetValue: Float

end value of the animation

initialVelocity: Float

start velocity of the animation

getVelocityFromNanos

open 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.

Parameters
playTimeNanos: Long

time since the start of the animation

initialValue: Float

start value of the animation

targetValue: Float

end value of the animation

initialVelocity: Float

start velocity of the animation

Public properties

delay

val delayInt

the amount of time the animation will wait before it starts running. Defaults to 0.

duration

val durationInt

the amount of time (in milliseconds) the animation will take to finish. Defaults to DefaultDurationMillis