react-native-dragsortable
Drag and drop sort control for react-native
Performance
Installation
yarn add react-native-dragsortableornpm i react-native-dragsortable --save
Example
import DragSortableView from 'DragSortableView';
this.state = {list:[]}const { list } = this.state;<DragSortableViewcolumnCount={4}onStartMove={() => {console.log("onStartMove");}}onDragStart={() => {console.log("onDragStart")}}onEndDrag={(items) => {console.log("onEndDrag", items)this.setState({list: items});}}renderItem={(item) => {// return item component}}data={list} />
API
- data: PropTypes.array.isRequired :
- maxSize: PropTypes.number.isRequired //item width/height
- columnCount: PropTypes.number.isRequired, //default row item count,if the totalWidth/columnCount(totalWidth=Dimensions.get('window').width) larger than maxSize,this columnCount value will be Math.floor(totalWidth/maxSize)
- sortable: PropTypes.bool, //default allow
- onStartMove: PropTypes.func, //click
- onDragStart: PropTypes.func,
- onDragEnd : PropTypes.func,
- renderItem : PropTypes.func.isRequired, //render item view