5. How can I reverse an animation?
The simplest approach to achieve reverse playback is to use the speed
prop on the LottieView
component, as negative values will make the animation play backward. If you want to play the animation in reverse but at its original speed, you need to set the speed
prop to –1
, but you can also play it at double speed by setting it to –2
or half-speed by changing it to –0.5
:
<LottieView
source={require('./assets/animations/loadingBar.json')}
speed={-1}
/>
If you are using the animated API to control the progress of your animation, you can use methods such as Animated.timing
, and make sure you are passing descending values:
// start animation at frame 300 and go decrementally to frame 0
const progress = useMemo(() => new Animated.Value(300), []);
useEffect(() => {
Animated.timing...