Drag to Sort with Reanimated and Gesture Handler ๐ค๐ฝ
Wednesday, December 20, 2023
demos
drag-to-sort
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A list component that allows reordering through drag and drop gestures. Includes visual feedback and position tracking.
What's This About?
This component creates a list where:
Items can be dragged to reorder
Visual feedback shows current position
Items adjust their shape while dragging
Gradient overlay adds depth
Technical Implementation
The component uses:
Reanimated for drag gestures
Custom list implementation for z-index handling
Position tracking with shared values
Linear gradient overlay
Safe area handling
Usage
type Item = {
id: string;
title: string;
// other item properties
};
// Basic usage
<SortableList
data={items}
listItemHeight={80}
onDragEnd={(positions) => {
console.log('New order:', positions);
}}
renderItem={({ item, index }) => (
<ListItem
item={item}
index={index}
style={{
height: 80,
margin: 6,
}}
/>
)}
/>;
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Drag To Sort
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback