LottieAnimatable

@Stable()
interface LottieAnimatable : LottieAnimationState

LottieAnimatable is an extension of LottieAnimationState that contains imperative suspend functions to control animation playback.

To create one, call:

val animatable = rememberLottieAnimatable()

This is the imperative version of animateLottieCompositionAsState.

LottieAnimationState ensures mutual exclusiveness on its animations. To achieve this, when a new animation is started via animate or snapTo, any ongoing animation will be canceled via a CancellationException. Because of this, it is possible that your animation will not start synchronously. As a result, if you switch from animating one composition to another, it is not safe to render the second composition immediately after calling animate. Instead, you should always rely on LottieAnimationState.composition and LottieAnimationState.progress.

This class is comparable to androidx.compose.animation.core.Animatable. It is a relatively low-level API that gives maximum control over animations. In most cases, you can use animateLottieCompositionAsState which provides declarative APIs to create, update, and animate a LottieComposition.

See also

Functions

animate
Link copied to clipboard
abstract suspend fun animate(composition: LottieComposition?, iteration: Int = this.iteration, iterations: Int = this.iterations, speed: Float = this.speed, clipSpec: LottieClipSpec? = this.clipSpec, initialProgress: Float = defaultProgress(composition, clipSpec, speed), continueFromPreviousAnimate: Boolean = false, cancellationBehavior: LottieCancellationBehavior = LottieCancellationBehavior.Immediately)
Animate a LottieComposition.
snapTo
Link copied to clipboard
abstract suspend fun snapTo(composition: LottieComposition? = this.composition, progress: Float = this.progress, iteration: Int = this.iteration, resetLastFrameNanos: Boolean = progress != this.progress)
Snap to a specific point in an animation.

Properties

clipSpec
Link copied to clipboard
abstract val clipSpec: LottieClipSpec?
composition
Link copied to clipboard
abstract val composition: LottieComposition?
isAtEnd
Link copied to clipboard
abstract val isAtEnd: Boolean
isPlaying
Link copied to clipboard
abstract val isPlaying: Boolean
iteration
Link copied to clipboard
abstract val iteration: Int
iterations
Link copied to clipboard
abstract val iterations: Int
lastFrameNanos
Link copied to clipboard
open val lastFrameNanos: Long
progress
Link copied to clipboard
abstract val progress: Float
speed
Link copied to clipboard
abstract val speed: Float
value
Link copied to clipboard
abstract val value: Float

Extensions

resetToBeginning
Link copied to clipboard
suspend fun LottieAnimatable.resetToBeginning()
Reset the animation back to the minimum progress and first iteration.