react-native-drag-sort
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -8,2 +8,3 @@ import React, {Component} from 'react' | ||
const sortRefs = new Map() | ||
const animMaps = new Map() | ||
const measureDelay = 100 | ||
@@ -128,4 +129,2 @@ const defaultZIndex = 8 | ||
} | ||
} | ||
@@ -206,2 +205,6 @@ | ||
nextItem = this.state.dataSource[index] | ||
} else if ((this.touchCurItem.index-moveToIndex > 0 && moveToIndex == index+1) || | ||
(this.touchCurItem.index-moveToIndex < 0 && moveToIndex == index-1)) { | ||
nextItem = this.state.dataSource[index] | ||
} | ||
@@ -399,3 +402,3 @@ | ||
if (this.props.onClickItem) { | ||
this.props.onClickItem(item.data,index) | ||
this.props.onClickItem(this.getOriginalData(),item.data,index) | ||
} | ||
@@ -402,0 +405,0 @@ }}> |
{ | ||
"name": "react-native-drag-sort", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Drag and drop sort control for react-native", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# react-native-drag-sort | ||
Drag and drop sort control for react-native | ||
![GitHub license](https://img.shields.io/badge/license-MIT-green.svg) | ||
[![npm](https://img.shields.io/npm/v/react-native-drag-sort.svg?style=flat)](https://npmjs.com/package/react-native-drag-sort) | ||
### Performance | ||
### Installation | ||
```bash | ||
yarn add react-native-drag-sort | ||
or | ||
npm i react-native-drag-sort --save | ||
``` | ||
### Example | ||
- [ScrollView](https://github.com/mochixuan/react-native-drag-sort/blob/master/Example/app/container/ScrollPage.js) | ||
- [View](https://github.com/mochixuan/react-native-drag-sort/blob/master/Example/app/container/NonScrollPage.js) | ||
- [Fixed Rows](https://github.com/mochixuan/react-native-drag-sort/blob/master/Example/app/container/FixedRowsPage.js) | ||
``` react | ||
<DragSortableView | ||
dataSource={this.state.data} | ||
parentWidth={parentWidth} | ||
childrenWidth= {childrenWidth} | ||
childrenHeight={childrenHeight} | ||
marginChildrenTop={marginChildrenTop} | ||
onDataChange = {(data)=>{ | ||
// delete or add data to refresh | ||
if (data.length != this.state.data.length) { | ||
this.setState({ | ||
data: data | ||
}) | ||
} | ||
}} | ||
onClickItem={(data,item,index)=>{}} | ||
renderItem={(item,index)=>{ | ||
return this.renderItem(item,index) | ||
}}/> | ||
``` | ||
### API | ||
- **dataSource**: PropTypes.array.isRequired : | ||
- **parentWidth**: PropTypes.number //parent width | ||
- **childrenHeight**: PropTypes.number.isRequired, //Each item height | ||
- **childrenWidth**: PropTypes.number.isRequired,//Each item width | ||
- **marginChildrenTop**: PropTypes.number, //So the item's outermost view adds margin, you can only use this method. | ||
- **marginChildrenBottom**: PropTypes.number, | ||
- **marginChildrenLeft** : PropTypes.number, | ||
- **marginChildrenRight** : PropTypes.number, | ||
- **sortable**: PropTypes.bool, //Do not allow dragging | ||
- **onClickItem**: PropTypes.func, //click | ||
- **onDragStart**: PropTypes.func, | ||
- **onDragEnd** : PropTypes.func, | ||
- **onDataChange** : PropTypes.func, //This method is called every time the data changes. | ||
- **renderItem** : PropTypes.func.isRequired, //render item view | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28199
384
65