react-native-dragsortable

1.0.6 • Public • Published

react-native-dragsortable

Drag and drop sort control for react-native

GitHub license npm

Performance

Installation

yarn add react-native-dragsortable
or
npm i react-native-dragsortable --save 

Example

import DragSortableView from 'DragSortableView';
this.state = {
    list:[]
}
 
const { list } = this.state;
<DragSortableView
    columnCount={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

Thanks

Package Sidebar

Install

npm i react-native-dragsortable

Weekly Downloads

1

Version

1.0.6

License

MIT

Unpacked Size

15.5 kB

Total Files

4

Last publish

Collaborators

  • zq513705971