$ git show ripple
Tap ripple
A circle grows from the exact tap point and fades out, clipped to the button.
Inspired by MaterialFrom William Candillon’s “Can it be done in React Native?” series. The code here is a simplified rewrite for Reanimated 4 and 3.
This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.
const cx = useSharedValue(0), cy = useSharedValue(0), p = useSharedValue(1);
const tap = Gesture.Tap().onBegin(e => {
cx.value = e.x; cy.value = e.y;
p.value = 0; p.value = withTiming(1, { duration: 500 });
});
const SIZE = Math.hypot(w, h) * 2; // w, h from onLayout
const ripple = useAnimatedStyle(() => ({
position: 'absolute', width: SIZE, height: SIZE, borderRadius: SIZE / 2,
left: cx.value - SIZE / 2, top: cy.value - SIZE / 2,
backgroundColor: 'rgba(255,255,255,0.35)',
opacity: 1 - p.value, transform: [{ scale: p.value }],
}));
// parent view needs overflow: 'hidden'