Choreography
Staggers, Sequences, and Parallel Sets
In order to make it possible to implement more complex transition animations, that may involve multiple components, Litho supports creating sets of animations that can run in parallel, in sequence, or on a stagger.
Sequences and staggers also support interrupting behavior, trying to preserve the guarantee that a component will never jump and will always end up in the correct final position.
Delays
Additionally, Litho provides .delay()
API that follows the same pattern.
These sets and delayed transitions can also be nested within each other, e.g. you can have a stagger of parallel animation sets.
Animators
By default, all transitions in Litho run by a spring Animator
with default configurations.
You can tune the parameters of this spring by creating another Animator
using Transition.springWith()
or you can choose to use timing-based Animator
s that could be created with Transition.timing()
.
To change the Animator
use .animator()
builder setting when creating your transition (lines 6, 9, 12):
Transition end callback
A listener can be added to receive a callback when an individual transition has ended. This is done through the Litho event dispatcher. See Events overview.
The TransitionEndEvent
will be called with the transition key and the specific AnimatedProperty
that has been animated for that key. If multiple AnimatedProperty
s are added to the same transition, and all of them run at the same time, a callback will be excecuted for each one of those.
You can also add the transition end handler to the Transition.allLayout()
and the same logic applies.