Shake to Delete with Reanimated 3
Wednesday, February 5, 2025
Scan to try on your device
Need the app?
reanimated
demos
shake-to-delete
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A simple shake to delete animation using Reanimated 3.
Of course, this animation is strongly inspired by the wiggle/shaking effect from the iOS Home Screen.
Usage
import { useShakingAnimation } from './hooks/use-shaking-animation';
import { useIsShaking } from './hooks/use-is-shaking';
const MyComponent = () => {
// Get shaking controls
const { isShaking, toggleShaking, stopShaking } = useIsShaking();
// Get shaking animation style for a specific item
const { rShakingStyle } = useShakingAnimation(1); // Unique ID for consistent animation
return (
<Pressable onPress={stopShaking}>
<Animated.View style={[styles.container, rShakingStyle]}>
<TouchableOpacity onLongPress={toggleShaking} onPress={handlePress}>
{/* Your content */}
</TouchableOpacity>
</Animated.View>
</Pressable>
);
};
Animation Parameters
You can customize the animation by modifying the animation config:
export const SHAKING_ANIMATION = {
BASE: {
AMPLITUDE: 1, // Base shake distance
AMPLITUDE_VARIATION: 0.2,
DURATION: 80, // Base animation duration (ms)
DURATION_VARIATION: 40,
ROTATION_AMPLITUDE: 1, // Base rotation angle
ROTATION_VARIATION: 2,
ROTATION_BASE: -3,
ROTATION_BASE_VARIATION: 6,
},
} as const;
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Shake To Delete
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback