withSequence
The withSequence
modifier allows you to chain multiple animations together, executing them one after another in the order they are defined. This is useful for creating complex, multi-step animations where each step needs to be completed before the next begins.
Syntax
withSequence(...animations: Animation[]) => Descriptor
Parameters
- ...animations: A series of animation descriptors (withSpring, withTiming, withDecay, etc.) that will be executed sequentially.
Example
This example shows how to chain multiple animations together using withSequence
. It demonstrates how different types of animations— spring
, timing
, delay
, and decay
—can be stitched together into one continuous flow.
What Happens Here:
- Springs to position (100, 100) smoothly (
withSpring
). - Then resizes its width & height to (200, 200) with a linear timing (
withTiming
). - Then it waits for 1000ms (
withDelay
). - Then moves back to the starting position (0, 0) over 3000ms (
withTiming
). - Finally, it applies decay animation on all properties (
withDecay
), causing them to slow down naturally based on momentum.