$ git show bottom-sheet
Bottom sheet
Drag-to-dismiss sheet with snap points and a velocity check.
This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.
const SNAPS = [0, 300]; // open, closed (translateY)
const y = useSharedValue(SNAPS[1]);
const start = useSharedValue(0);
const pan = Gesture.Pan()
.onStart(() => { start.value = y.value; })
.onUpdate(e => { y.value = clamp(start.value + e.translationY, 0, SNAPS[1]); })
.onEnd(e => {
const target = e.velocityY > 500 || y.value > SNAPS[1] / 2 ? SNAPS[1] : SNAPS[0];
y.value = withSpring(target, { damping: 20 });
});
const style = useAnimatedStyle(() => ({ transform: [{ translateY: y.value }] }));