Component - Spring and decay animations
This React Native component shows how spring and decay animations move a box smoothly. The spring animation bounces the box to a target position, while the decay animation slows it down naturally.
This React Native component shows how spring and decay animations move a box smoothly. The spring animation bounces the box to a target position, while the decay animation slows it down naturally.
View ├─ Animated.View └─ View ├─ Button (Start Spring) └─ Button (Start Decay)
const anim = new Animated.Value(0);
Animated.decay(anim, {velocity: 3, deceleration: 0.997}).start();
anim.addListener(({value}) => console.log(value));const anim = new Animated.Value(0);
Animated.spring(anim, {toValue: 1, velocity: 5}).run();Pass the test and this pattern moves unknown