$ git show stepper
Quantity stepper
Plus and minus buttons where the number rolls in from the direction you pressed.
−+
// Unchanged in Reanimated 4: Keyframe entering/exiting animations work the same
import Animated, { Keyframe } from 'react-native-reanimated';
const enterFrom = (dy) => new Keyframe({
0: { opacity: 0, transform: [{ translateY: dy }] },
100: { opacity: 1, transform: [{ translateY: 0 }] },
}).duration(220);
const exitTo = (dy) => new Keyframe({
0: { opacity: 1, transform: [{ translateY: 0 }] },
100: { opacity: 0, transform: [{ translateY: dy }] },
}).duration(220);
const [value, setValue] = useState(3);
const [dir, setDir] = useState(1);
const change = (d) => { setDir(d); setValue((v) => Math.max(0, v + d)); };
<View style={styles.stepper}>
<Pressable onPress={() => change(-1)}><Text style={styles.btn}>−</Text></Pressable>
<View style={{ width: 32, height: 28, overflow: 'hidden', alignItems: 'center' }}>
<Animated.Text
key={value}
entering={enterFrom(dir * 16)}
exiting={exitTo(dir * -16)}
style={[styles.value, { position: 'absolute' }]}>
{value}
</Animated.Text>
</View>
<Pressable onPress={() => change(1)}><Text style={styles.btn}>+</Text></Pressable>
</View>