Swipe Cards with React Native Reanimated
Wednesday, June 12, 2024
demos
imessage-stack
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A horizontal scrolling stack of cards inspired by iMessage interactions.
What's This About?
This component creates a horizontally scrollable stack of cards that mimics the behavior of iMessage's media browser. It uses a single ScrollView with paging enabled to handle an infinite number of cards smoothly. The implementation focuses on performance and smooth animations by leveraging native scroll behavior instead of custom gesture handlers. Each card can be customized with different colors and content.
Technical Implementation
The component uses:
Reanimated ScrollView
Paging behavior
Scroll offset tracking
Card positioning
Custom styling
Usage
// Card configuration
const CARD_HEIGHT = 100;
const CARD_WIDTH = 100;
// Sample cards data
const CARDS = [
{ color: '#F1EEE0' },
{ color: '#F3D9BC' },
{ color: '#F4ACB7' },
// ... more cards
];
// Basic usage
<IMessageStack />
// ScrollView configuration
<Animated.ScrollView
horizontal
snapToInterval={CARD_WIDTH}
disableIntervalMomentum
pagingEnabled
showsHorizontalScrollIndicator={false}
decelerationRate="fast"
/>
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Imessage Stack
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback