Transition
Transition manages all the child animations on a state level. Child animations can be created in a declarative way using Transition.animateFloat, Transition.animateValue, animateColor etc. When the targetState changes, Transition will automatically start or adjust course for all its child animations to animate to the new target values defined for each animation.
After arriving at targetState, Transition will be triggered to run if any child animation changes its target value (due to their dynamic target calculation logic, such as theme-dependent values).
See also
Types
DeferredAnimation can be constructed using Transition.createDeferredAnimation during composition and initialized later. It is useful for animations, the target values for which are unknown at composition time (e.g. layout size/position, etc).
Segment holds initialState and targetState, which are the beginning and end of a transition. These states will be used to obtain the animation spec that will be used for this transition from the child animations.
Each animation created using animateFloat, etc is represented as a TransitionAnimationState in Transition.
Properties
List of TransitionAnimationStates that are in a Transition.
Current state of the transition. This will always be the initialState of the transition until the transition is finished. Once the transition is finished, currentState will be set to targetState. currentState is backed by a MutableState.
segment contains the initial state and the target state of the currently on-going transition.
Target state of the transition. This will be read by all child animations to determine their most up-to-date target values.
Total duration of the Transition, accounting for all the animations and child transitions defined on the Transition.
List of child transitions in a Transition.
Functions
Creates a Color animation as a part of the given Transition. This means the lifecycle of this animation will be managed by the Transition.
Creates a Float animation as a part of the given Transition. This means the states of this animation will be managed by the Transition.
Creates a Int animation as a part of the given Transition. This means the states of this animation will be managed by the Transition.
Creates a IntOffset animation as a part of the given Transition. This means the states of this animation will be managed by the Transition.
Creates a IntSize animation as a part of the given Transition. This means the states of this animation will be managed by the Transition.
Creates an animation of type T as a part of the given Transition. This means the states of this animation will be managed by the Transition. typeConverter will be used to convert between type T and AnimationVector so that the animation system knows how to animate it.
createChildTransition creates a child Transition based on the mapping between parent state to child state provided in transformToChildState. This serves the following purposes:
This creates a DeferredAnimation, which will not animate until it is set up using DeferredAnimation.animate. Once the animation is set up, it will animate from the currentState to targetState. If the Transition has already arrived at its target state at the time when the animation added, there will be no animation.