Google is committed to advancing racial equity for Black communities. See how.

TransitionAnimation

class TransitionAnimation<T> : TransitionState
kotlin.Any
   ↳ androidx.compose.animation.core.TransitionAnimation

TransitionAnimation is the underlying animation used in androidx.compose.animation.transition for animating from one set of property values (i.e. one TransitionState) to another. In compose, it is recommended to create such an animation using androidx.compose.animation.transition, instead of instantiating TransitionAnimation directly.

TransitionAnimation reads the property values out of the start and end state, as well as the animations defined for each state pair for each property, and run these animations until all properties have reached their pre-defined values in the new state. When no animation is specified for a property, a default FloatSpringSpec animation will be used.

TransitionAnimation may be interrupted while the animation is on-going by a request to go to another state. TransitionAnimation ensures that all the animating properties preserve their current value and velocity as they createAnimation to the new state.

Once a TransitionDefinition is instantiated, a TransitionAnimation can be created via TransitionDefinition.createAnimation.

Summary

Public constructors
<init>(def: TransitionDefinition<T>, clock: AnimationClockObservable, initState: T? = null, label: String? = null)

TransitionAnimation is the underlying animation used in androidx.compose.animation.transition for animating from one set of property values (i.

Public methods
operator T
get(propKey: PropKey<T, V>)

Gets the value of a property with a given property key.

Unit
toState(name: T)

Starts the animation to go to a new state with the given state name.

Properties
Boolean

String?

Optional label for distinguishing different transitions in Android Studio.

(T) -> Unit

() -> Unit

Public constructors

<init>

TransitionAnimation(
    def: TransitionDefinition<T>,
    clock: AnimationClockObservable,
    initState: T? = null,
    label: String? = null)

TransitionAnimation is the underlying animation used in androidx.compose.animation.transition for animating from one set of property values (i.e. one TransitionState) to another. In compose, it is recommended to create such an animation using androidx.compose.animation.transition, instead of instantiating TransitionAnimation directly.

TransitionAnimation reads the property values out of the start and end state, as well as the animations defined for each state pair for each property, and run these animations until all properties have reached their pre-defined values in the new state. When no animation is specified for a property, a default FloatSpringSpec animation will be used.

TransitionAnimation may be interrupted while the animation is on-going by a request to go to another state. TransitionAnimation ensures that all the animating properties preserve their current value and velocity as they createAnimation to the new state.

Once a TransitionDefinition is instantiated, a TransitionAnimation can be created via TransitionDefinition.createAnimation.

Parameters
def: TransitionDefinition<T> Transition definition that defines states and transitions
clock: AnimationClockObservable Optional animation clock that pulses animations when time changes. By default, the system uses a choreographer based clock read from the AnimationClockAmbient. A custom implementation of the AnimationClockObservable (such as a androidx.compose.animation.core.ManualAnimationClock) can be supplied here if there’s a need to manually control the clock (for example in tests).
initState: T? = null Optional initial state for the transition. When undefined, the initial state will be set to the first toState seen in the transition.
label: String? = null Optional label for distinguishing different transitions in Android Studio.

Public methods

get

operator fun <T, V : AnimationVector> get(propKey: PropKey<T, V>): T

Gets the value of a property with a given property key.

Parameters
propKey: PropKey<T, V> Property key (defined in TransitionDefinition) for a specific property

toState

fun toState(name: T): Unit

Starts the animation to go to a new state with the given state name.

Parameters
name: T Name of the TransitionState that is defined in the TransitionDefinition.

Properties

isRunning

var isRunning: Boolean

label

val label: String?

Optional label for distinguishing different transitions in Android Studio.

onStateChangeFinished

var onStateChangeFinished: (T) -> Unit

onUpdate

var onUpdate: () -> Unit