Interactive Examples Showcase
A comprehensive collection of 15 interactive examples demonstrating every feature of the React Native Reanimated DnD library.
This example app provides a hands-on demonstration of all the features available in the react-native-reanimated-dnd library. Each example is carefully crafted to showcase specific functionality, from basic drag-and-drop to advanced collision detection and custom animations.
- Node.js 20+
- React Native development environment
- iOS Simulator or Android Emulator (or physical device)
- Clone the repository:
git clone https://github.com/entropyconquers/react-native-reanimated-dnd.git
cd react-native-reanimated-dnd- Install dependencies:
npm install- Run the app:
# Development server
npm run start --workspace example-app
# iOS development build
npm run ios --workspace example-app
# Android development build
npm run android --workspace example-appPerfect introduction to sortable lists
Features Demonstrated:
- Reorderable vertical list with smooth animations
- Drag handles for precise control
- Auto-scrolling when dragging near edges
- Real-time position updates and data synchronization
- Long-press activation with haptic feedback
Key Components: Sortable, SortableItem, SortableItem.Handle
Use Cases: Music playlists, task lists, priority queues, menu reordering
Your first step into drag-and-drop
Features Demonstrated:
- Simple draggable items with multiple drop zones
- Visual feedback when hovering over drop zones
- Basic data transfer between components
- Clean, minimal implementation pattern
Key Components: Draggable, Droppable, DropProvider
Use Cases: File organization, category sorting, simple workflows
Precise control over drag initiation
Features Demonstrated:
- Handle-only dragging (rest of item non-draggable)
- Mixed interaction patterns within single items
- Custom handle styling and positioning
- Accessibility considerations for touch targets
Key Components: Draggable.Handle
Use Cases: Complex UI cards, mixed-interaction lists, accessibility-focused designs
Complete lifecycle state tracking
Features Demonstrated:
DraggableStateenum usage (IDLE,DRAGGING,ANIMATING)onStateChangecallback implementation- Visual state indicators and conditional styling
- State-based UI updates and animations
Key Components: State management hooks and callbacks
Use Cases: Complex UI feedback, analytics tracking, conditional behaviors
Real-time tracking of drop relationships
Features Demonstrated:
- Track which draggables are on which droppables
- Real-time mapping updates
- Multi-zone state management
- Persistent state across interactions
Key Components: Context state management
Use Cases: Kanban boards, inventory management, workspace organization
Bring your drag interactions to life
Features Demonstrated:
- Custom timing functions with
withTiming - Spring animations with
withSpring - Easing variations (bezier, bounce, elastic)
- Duration and damping controls
- Chained and sequential animations
Key Components: Animation functions, animationFunction prop
Use Cases: Premium app experiences, game-like interactions, brand-specific animations
Beautiful visual feedback
Features Demonstrated:
- Hover state styling with smooth transitions
- Color changes and border effects
- Scale transformations and shadow effects
- Conditional styling based on drop state
- CSS-like transition animations
Key Components: activeStyle prop, conditional styling
Use Cases: File upload zones, shopping carts, interactive dashboards
Pixel-perfect drop positioning
Features Demonstrated:
- 9-point alignment system (top-left, center, bottom-right, etc.)
- Custom offset values for fine-tuning
- Visual alignment guides and indicators
- Precise positioning control
Key Components: dropAlignment, dropOffset props
Use Cases: Layout builders, design tools, precise positioning requirements
Different strategies for drop detection
Features Demonstrated:
- Center Algorithm: Precise center-point collision detection
- Intersect Algorithm: Forgiving overlap detection (default)
- Contain Algorithm: Strict containment requirement
- Visual collision indicators and feedback
- Performance implications of each algorithm
Key Components: collisionAlgorithm prop
Use Cases: Games, precise interactions, different UX requirements
Smart capacity management
Features Demonstrated:
- Maximum item limits per drop zone
- Visual capacity indicators (3/5 items)
- Overflow handling and rejection
- Dynamic capacity updates
- Full/available state styling
Key Components: capacity prop, conditional logic
Use Cases: Limited slots, inventory systems, resource management
Keep items within boundaries
Features Demonstrated:
- Container-based boundary constraints
- Visual boundary indicators
- Smooth edge collision handling
- Responsive boundary updates
- Ref-based boundary definition
Key Components: dragBoundsRef prop
Use Cases: Canvas editors, constrained workspaces, mobile-friendly interactions
Horizontal-only movement
Features Demonstrated:
- Horizontal slider implementations
- Axis-locked dragging behavior
- Custom constraint handling
- Smooth horizontal motion
- Value-based positioning
Key Components: dragAxis="x" prop
Use Cases: Sliders, horizontal timelines, progress controls
Vertical-only movement
Features Demonstrated:
- Vertical slider controls
- Column-based movement patterns
- Vertical constraint handling
- Smooth vertical motion
- List reordering patterns
Key Components: dragAxis="y" prop
Use Cases: Volume controls, vertical lists, priority ordering
Vertical movement with limits
Features Demonstrated:
- Vertical movement within specific boundaries
- Combined axis and boundary constraints
- Boundary visualization
- Smooth constraint handling
- Range-based interactions
Key Components: dragAxis="y" + dragBoundsRef
Use Cases: Range selectors, bounded lists, constrained vertical controls
Advanced implementation patterns
Features Demonstrated:
- Direct hook usage (
useDraggable,useDroppable) - Advanced gesture handling patterns
- Custom animation systems
- Performance optimization techniques
- Low-level API usage
Key Components: Core hooks and custom implementations
Use Cases: Highly customized interactions, performance-critical apps, unique UX patterns
📱 App
├── 🏠 Home (Examples Navigation)
├── 🎵 Sortable Music Queue
├── 👆 Basic Drag & Drop
├── 🔧 Drag Handles
├── ⚡ Drag State Management
├── 📍 Dropped Items Map
├── 🎬 Custom Animations
├── ✨ Active Drop Styles
├── 📐 Alignment & Offset
├── 🎯 Collision Detection
├── 🗂️ Drop Zone Capacity
├── 📦 Bounded Dragging
├── ↔️ X-Axis Constraints
├── ↕️ Y-Axis Constraints
├── 📏 Bounded Y-Axis
└── ⚙️ Custom Draggable
- Beautiful home screen with example cards
- Categorized example organization
- Smooth navigation transitions
- Custom fonts and styling
- Consistent header with back navigation
- Interactive demonstrations
- Real-time feedback and state display
- Clean, educational code patterns
ExampleHeader- Consistent navigationFooter- App information and linksBottomSheet- Settings and options
- Primary Font: Major Mono Display (headers)
- Body Font: Kumbh Sans (content)
- Weights: Regular, Medium, SemiBold, Bold
- Background: Deep black (#000000)
- Cards: Dark gray with subtle borders
- Accent: Red highlights for branding
- Text: High contrast white/gray
- Interactive: Blue and green for actions
- Duration: 300ms standard, 200ms quick
- Easing: Smooth bezier curves
- Spring: Natural physics-based motion
- Feedback: Haptic feedback on interactions
{
"react-native-reanimated": "^3.5.0",
"react-native-gesture-handler": "^2.13.0",
"@react-navigation/native": "^6.1.0",
"@react-navigation/stack": "^6.3.0",
"expo": "~49.0.0"
}- Worklet Functions: All animations run on UI thread
- Gesture Handler: Native gesture recognition
- Reanimated 3: Latest performance improvements
- Memoization: Optimized re-renders
- Lazy Loading: Efficient navigation
📁 example-app/
├── 📁 components/
│ ├── 📁 examples/ # All example implementations
│ ├── ExamplesNavigationPage.tsx
│ ├── ExampleHeader.tsx
│ └── Footer.tsx
├── 📁 navigation/
│ └── AppNavigator.tsx # React Navigation setup
├── 📁 assets/ # Images and fonts
└── App.tsx # Root component
- Basic Drag & Drop - Understand core concepts
- Sortable Music Queue - Learn list reordering
- Active Drop Styles - Add visual feedback
- Drag Handles - Implement precise controls
- Collision Detection - Understand algorithms
- Bounded Dragging - Add constraints
- Custom Animations - Enhance user experience
- Drag State Management - Master state tracking
- Dropped Items Map - Complex state management
- Alignment & Offset - Precise positioning
- Capacity Management - Smart limitations
- Axis Constraints - Specialized interactions
- Custom Implementation - Build from scratch
We welcome contributions to improve and expand the example collection!
- Create new component in
components/examples/ - Add to navigation in
AppNavigator.tsx - Update
ExamplesNavigationPage.tsx - Follow existing patterns and styling
- Enhance visual design
- Add more interactive features
- Improve code comments and documentation
- Optimize performance
- iOS: iPhone 12+ (iOS 14+)
- Android: API 21+ (Android 5.0+)
- Tablets: iPad, Android tablets
- Physical Devices: Best performance testing
- Animations run at 60fps on modern devices
- Gesture recognition is native and responsive
- Memory usage is optimized for mobile
- Works well on both platforms
- Main Library: react-native-reanimated-dnd
- Documentation: API Reference
- React Native Reanimated: Official Docs
- Gesture Handler: Official Docs
🎯 Ready to explore drag-and-drop interactions?
Run the app and start with the Basic Drag & Drop example!