VectorizedRepeatableSpec
class VectorizedRepeatableSpec<V : AnimationVector> : VectorizedFiniteAnimationSpec<V>
kotlin.Any | |
↳ | androidx.compose.animation.core.VectorizedRepeatableSpec |
This animation takes another VectorizedDurationBasedAnimationSpec and plays it iterations times. For infinitely repeating animation spec, VectorizedInfiniteRepeatableSpec is recommended.
Note: When repeating in the RepeatMode.Reverse mode, it's highly recommended to have an odd number of iterations. Otherwise, the animation may jump to the end value when it finishes the last iteration.
Summary
Public constructors | |
---|---|
<init>(iterations: Int, animation: VectorizedDurationBasedAnimationSpec<V>, repeatMode: RepeatMode = RepeatMode.Restart) This animation takes another VectorizedDurationBasedAnimationSpec and plays it iterations times. |
Public methods | |
---|---|
Long |
getDurationMillis(start: V, end: V, startVelocity: V) Calculates the duration of an animation. |
V |
Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity. |
V |
getVelocity(playTime: Long, start: V, end: V, startVelocity: V) Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity. |
Public constructors
<init>
VectorizedRepeatableSpec(
iterations: Int,
animation: VectorizedDurationBasedAnimationSpec<V>,
repeatMode: RepeatMode = RepeatMode.Restart)
This animation takes another VectorizedDurationBasedAnimationSpec and plays it iterations times. For infinitely repeating animation spec, VectorizedInfiniteRepeatableSpec is recommended.
Note: When repeating in the RepeatMode.Reverse mode, it's highly recommended to have an odd number of iterations. Otherwise, the animation may jump to the end value when it finishes the last iteration.
Parameters | |
---|---|
iterations: Int | the count of iterations. Should be at least 1. |
animation: VectorizedDurationBasedAnimationSpec<V> | the VectorizedAnimationSpec describing each repetition iteration. |
repeatMode: RepeatMode = RepeatMode.Restart | whether animation should repeat by starting from the beginning (i.e. RepeatMode.Restart) or from the end (i.e. RepeatMode.Reverse) |
Public methods
getDurationMillis
fun getDurationMillis(
start: V,
end: V,
startVelocity: V
): 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 start, end values, and startVelocity.
Parameters | |
---|---|
start: V | start value of the animation |
end: V | end value of the animation |
startVelocity: V | start velocity of the animation |
getValue
fun getValue(
playTime: Long,
start: V,
end: V,
startVelocity: V
): V
Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.
Parameters | |
---|---|
playTime: Long | time since the start of the animation |
start: V | start value of the animation |
end: V | end value of the animation |
startVelocity: V | start velocity of the animation |
getVelocity
fun getVelocity(
playTime: Long,
start: V,
end: V,
startVelocity: V
): V
Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.
Parameters | |
---|---|
playTime: Long | time since the start of the animation |
start: V | start value of the animation |
end: V | end value of the animation |
startVelocity: V | start velocity of the animation |