VectorizedRepeatableSpec

class VectorizedRepeatableSpec<V : AnimationVector>(iterations: Int, animation: VectorizedDurationBasedAnimationSpec<V>, repeatMode: RepeatMode = RepeatMode.Restart, initialStartOffset: StartOffset = StartOffset(0)) : VectorizedFiniteAnimationSpec<V>

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.

initialStartOffset can be used to either delay the start of the animation or to fast forward the animation to a given play time. This start offset will not be repeated, whereas the delay in the animation (if any) will be repeated. By default, the amount of offset is 0.

Parameters

iterations

the count of iterations. Should be at least 1.

animation

the VectorizedAnimationSpec describing each repetition iteration.

repeatMode

whether animation should repeat by starting from the beginning (i.e. RepeatMode.Restart) or from the end (i.e. RepeatMode.Reverse)

initialStartOffset

offsets the start of the animation

Constructors

Link copied to clipboard
constructor(iterations: Int, animation: VectorizedDurationBasedAnimationSpec<V>, repeatMode: RepeatMode = RepeatMode.Restart, initialStartOffset: StartOffset = StartOffset(0))

Properties

Link copied to clipboard
open override val isInfinite: Boolean

Whether or not the VectorizedAnimationSpec specifies an infinite animation. That is, one that will not finish by itself, one that needs an external action to stop. For examples, an indeterminate progress bar, which will only stop when it is removed from the composition.

Functions

Link copied to clipboard
@RestrictTo(value = [RestrictTo.Scope.LIBRARY])
fun <V : AnimationVector> VectorizedAnimationSpec<V>.createAnimation(initialValue: V, targetValue: V, initialVelocity: V): TargetBasedAnimation<V, V>

Creates a TargetBasedAnimation from a given com.jakewharton.mosaic.animation.VectorizedAnimationSpec of AnimationVector type. This convenient method is intended for when the value being animated (i.e. start value, end value, etc) is of AnimationVector type.

Link copied to clipboard
open override fun getDurationNanos(initialValue: V, targetValue: V, initialVelocity: 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 initialValue, targetValue values, and initialVelocity.

Link copied to clipboard
open fun getEndVelocity(initialValue: V, targetValue: V, initialVelocity: V): V

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 physics-based animations, end velocity is an AnimationVector of 0s.

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

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

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

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