react-native-drag-sort
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -17,12 +17,12 @@ import React, {Component} from 'react' | ||
this.itemWidth = props.childrenWidth+props.marginChildrenLeft+props.marginChildrenRight | ||
this.itemHeight = props.childrenHeight+props.marginChildrenTop+props.marginChildrenBottom | ||
const itemWidth = props.childrenWidth+props.marginChildrenLeft+props.marginChildrenRight | ||
const itemHeight = props.childrenHeight + props.marginChildrenTop + props.marginChildrenBottom | ||
// this.reComplexDataSource(true,props) // react < 16.3 | ||
// react > 16.3 Fiber | ||
const rowNum = parseInt(props.parentWidth / this.itemWidth); | ||
const rowNum = parseInt(props.parentWidth / itemWidth); | ||
const dataSource = props.dataSource.map((item, index) => { | ||
const newData = {} | ||
const left = (index % rowNum) * this.itemWidth | ||
const top = parseInt((index / rowNum)) * this.itemHeight | ||
const left = (index % rowNum) * itemWidth | ||
const top = parseInt((index / rowNum)) * itemHeight | ||
@@ -43,3 +43,5 @@ newData.data = item | ||
curPropsDataSource: props.dataSource, | ||
height: Math.ceil(dataSource.length / rowNum) * this.itemHeight, | ||
height: Math.ceil(dataSource.length / rowNum) * itemHeight, | ||
itemWidth, | ||
itemHeight, | ||
}; | ||
@@ -74,5 +76,6 @@ | ||
static getDerivedStateFromProps(nextprops, prevState) { | ||
if (nextprops.dataSource != prevState.curPropsDataSource) { | ||
const itemWidth = nextprops.childrenWidth + nextprops.marginChildrenLeft + nextprops.marginChildrenRight | ||
const itemHeight = nextprops.childrenHeight + nextprops.marginChildrenTop + nextprops.marginChildrenBottom | ||
const itemWidth = nextprops.childrenWidth + nextprops.marginChildrenLeft + nextprops.marginChildrenRight | ||
const itemHeight = nextprops.childrenHeight + nextprops.marginChildrenTop + nextprops.marginChildrenBottom | ||
if (nextprops.dataSource != prevState.curPropsDataSource || itemWidth !== prevState.itemWidth || itemHeight !== prevState.itemHeight) { | ||
const rowNum = parseInt(nextprops.parentWidth / itemWidth); | ||
@@ -98,6 +101,7 @@ const dataSource = nextprops.dataSource.map((item, index) => { | ||
curPropsDataSource: nextprops.dataSource, | ||
height: Math.ceil(dataSource.length / rowNum) * itemHeight | ||
height: Math.ceil(dataSource.length / rowNum) * itemHeight, | ||
itemWidth, | ||
itemHeight, | ||
} | ||
} | ||
return null; | ||
@@ -236,6 +240,8 @@ } | ||
let {dx, dy, vy} = gestureState; | ||
const itemWidth = this.state.itemWidth; | ||
const itemHeight = this.state.itemHeight; | ||
const rowNum = parseInt(this.props.parentWidth/this.itemWidth); | ||
const maxWidth = this.props.parentWidth-this.itemWidth; | ||
const maxHeight = this.itemHeight*Math.ceil(this.state.dataSource.length/rowNum) - this.itemHeight; | ||
const rowNum = parseInt(this.props.parentWidth/itemWidth); | ||
const maxWidth = this.props.parentWidth-itemWidth; | ||
const maxHeight = itemHeight*Math.ceil(this.state.dataSource.length/rowNum) - itemHeight; | ||
@@ -317,4 +323,4 @@ // Is it free to drag | ||
let moveToIndex = 0 | ||
let moveXNum = dx/this.itemWidth | ||
let moveYNum = dy/this.itemHeight | ||
let moveXNum = dx/itemWidth | ||
let moveYNum = dy/itemHeight | ||
if (moveXNum > 0) { | ||
@@ -494,7 +500,9 @@ moveXNum = parseInt(moveXNum+0.5) | ||
reComplexDataSource(isInit,props) { | ||
const rowNum = parseInt(props.parentWidth/this.itemWidth); | ||
const itemWidth = this.state.itemWidth; | ||
const itemHeight = this.state.itemHeight; | ||
const rowNum = parseInt(props.parentWidth/itemWidth); | ||
const dataSource = props.dataSource.map((item,index)=>{ | ||
const newData = {} | ||
const left = (index%rowNum)*this.itemWidth | ||
const top = parseInt((index/rowNum))*this.itemHeight | ||
const left = (index%rowNum)*itemWidth | ||
const top = parseInt((index/rowNum))*itemHeight | ||
@@ -517,3 +525,3 @@ newData.data = item | ||
dataSource: dataSource, | ||
height: Math.ceil(dataSource.length/rowNum)*this.itemHeight | ||
height: Math.ceil(dataSource.length/rowNum)*itemHeight | ||
} | ||
@@ -523,3 +531,3 @@ } else { | ||
dataSource: dataSource, | ||
height: Math.ceil(dataSource.length/rowNum)*this.itemHeight | ||
height: Math.ceil(dataSource.length/rowNum)*itemHeight | ||
}) | ||
@@ -526,0 +534,0 @@ } |
@@ -17,12 +17,12 @@ import React, {Component} from 'react' | ||
this.itemWidth = props.childrenWidth+props.marginChildrenLeft+props.marginChildrenRight | ||
this.itemHeight = props.childrenHeight+props.marginChildrenTop+props.marginChildrenBottom | ||
const itemWidth = props.childrenWidth+props.marginChildrenLeft+props.marginChildrenRight | ||
const itemHeight = props.childrenHeight+props.marginChildrenTop+props.marginChildrenBottom | ||
// this.reComplexDataSource(true,props) // react < 16.3 | ||
// react > 16.3 Fiber | ||
const rowNum = parseInt(props.parentWidth/this.itemWidth); | ||
const rowNum = parseInt(props.parentWidth/itemWidth); | ||
const dataSource = props.dataSource.map((item,index)=>{ | ||
const newData = {} | ||
const left = (index%rowNum)*this.itemWidth | ||
const top = parseInt((index/rowNum))*this.itemHeight | ||
const left = (index%rowNum)*itemWidth | ||
const top = parseInt((index/rowNum))*itemHeight | ||
@@ -43,3 +43,5 @@ newData.data = item | ||
curPropsDataSource: props.dataSource, | ||
height: Math.ceil(dataSource.length / rowNum) * this.itemHeight, | ||
height: Math.ceil(dataSource.length / rowNum) * itemHeight, | ||
itemWidth, | ||
itemHeight, | ||
}; | ||
@@ -73,11 +75,12 @@ | ||
// react > 16.3 Fiber | ||
static getDerivedStateFromProps(nextprops,prevState) { | ||
if (nextprops.dataSource != prevState.curPropsDataSource) { | ||
const itemWidth = nextprops.childrenWidth + nextprops.marginChildrenLeft + nextprops.marginChildrenRight | ||
const itemHeight = nextprops.childrenHeight + nextprops.marginChildrenTop + nextprops.marginChildrenBottom | ||
const rowNum = parseInt (nextprops.parentWidth / itemWidth); | ||
const dataSource = nextprops.dataSource.map ((item, index) => { | ||
static getDerivedStateFromProps(nextprops, prevState) { | ||
const itemWidth = nextprops.childrenWidth + nextprops.marginChildrenLeft + nextprops.marginChildrenRight | ||
const itemHeight = nextprops.childrenHeight + nextprops.marginChildrenTop + nextprops.marginChildrenBottom | ||
if (nextprops.dataSource != prevState.curPropsDataSource || itemWidth !== prevState.itemWidth || itemHeight !== prevState.itemHeight) { | ||
const rowNum = parseInt(nextprops.parentWidth / itemWidth); | ||
const dataSource = nextprops.dataSource.map((item, index) => { | ||
const newData = {}; | ||
const left = index % rowNum * itemWidth; | ||
const top = parseInt (index / rowNum) * itemHeight; | ||
const top = parseInt(index / rowNum) * itemHeight; | ||
@@ -88,7 +91,7 @@ newData.data = item; | ||
newData.originTop = top; | ||
newData.position = new Animated.ValueXY ({ | ||
x: parseInt (left + 0.5), | ||
y: parseInt (top + 0.5), | ||
newData.position = new Animated.ValueXY({ | ||
x: parseInt(left + 0.5), | ||
y: parseInt(top + 0.5), | ||
}); | ||
newData.scaleValue = new Animated.Value (1); | ||
newData.scaleValue = new Animated.Value(1); | ||
return newData; | ||
@@ -99,6 +102,7 @@ }); | ||
curPropsDataSource: nextprops.dataSource, | ||
height: Math.ceil(dataSource.length/rowNum)*itemHeight | ||
height: Math.ceil(dataSource.length / rowNum) * itemHeight, | ||
itemWidth, | ||
itemHeight, | ||
} | ||
} | ||
return null; | ||
@@ -154,6 +158,8 @@ } | ||
let dy = gestureState.dy | ||
const itemWidth = this.state.itemWidth; | ||
const itemHeight = this.state.itemHeight; | ||
const rowNum = parseInt(this.props.parentWidth/this.itemWidth); | ||
const maxWidth = this.props.parentWidth-this.itemWidth | ||
const maxHeight = this.itemHeight*Math.ceil(this.state.dataSource.length/rowNum) - this.itemHeight | ||
const rowNum = parseInt(this.props.parentWidth/itemWidth); | ||
const maxWidth = this.props.parentWidth-itemWidth | ||
const maxHeight = itemHeight*Math.ceil(this.state.dataSource.length/rowNum) - itemHeight | ||
@@ -190,4 +196,4 @@ // Is it free to drag | ||
let moveToIndex = 0 | ||
let moveXNum = dx/this.itemWidth | ||
let moveYNum = dy/this.itemHeight | ||
let moveXNum = dx/itemWidth | ||
let moveYNum = dy/itemHeight | ||
if (moveXNum > 0) { | ||
@@ -364,7 +370,9 @@ moveXNum = parseInt(moveXNum+0.5) | ||
reComplexDataSource(isInit,props) { | ||
const rowNum = parseInt(props.parentWidth/this.itemWidth); | ||
const itemWidth = this.state.itemWidth; | ||
const itemHeight = this.state.itemHeight; | ||
const rowNum = parseInt(props.parentWidth/itemWidth); | ||
const dataSource = props.dataSource.map((item,index)=>{ | ||
const newData = {} | ||
const left = (index%rowNum)*this.itemWidth | ||
const top = parseInt((index/rowNum))*this.itemHeight | ||
const left = (index%rowNum)*itemWidth | ||
const top = parseInt((index/rowNum))*itemHeight | ||
@@ -386,3 +394,3 @@ newData.data = item | ||
dataSource: dataSource, | ||
height: Math.ceil(dataSource.length/rowNum)*this.itemHeight | ||
height: Math.ceil(dataSource.length/rowNum)*itemHeight | ||
} | ||
@@ -392,3 +400,3 @@ } else { | ||
dataSource: dataSource, | ||
height: Math.ceil(dataSource.length/rowNum)*this.itemHeight | ||
height: Math.ceil(dataSource.length/rowNum)*itemHeight | ||
}) | ||
@@ -395,0 +403,0 @@ } |
{ | ||
"name": "react-native-drag-sort", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Drag and drop sort control for react-native", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
82892
1093