feat: onDropRow增加参数targetIndex

This commit is contained in:
yangchch6 2020-07-29 13:45:37 +08:00
parent 54f77ec52e
commit 17bf7b9c49
6 changed files with 45 additions and 55 deletions

View File

@ -239,11 +239,15 @@ var Table = function (_Component) {
targetIndex = i; targetIndex = i;
} }
}); });
if (currentIndex > -1) {
data = _this.swapArray(data, currentIndex, targetIndex); data = _this.swapArray(data, currentIndex, targetIndex);
_this.props.onDropRow && _this.props.onDropRow(data, record); _this.props.onDropRow && _this.props.onDropRow(data, record, targetIndex);
_this.setState({ _this.setState({
data: data data: data
}); });
} else {
_this.props.onDropRow && _this.props.onDropRow(data, record, targetIndex);
}
}; };
_this.swapArray = function (arr, index1, index2) { _this.swapArray = function (arr, index1, index2) {
@ -1556,6 +1560,9 @@ var Table = function (_Component) {
this.lastScrollTop = e.target.scrollTop; this.lastScrollTop = e.target.scrollTop;
if (handleScrollY) { if (handleScrollY) {
(0, _utils.debounce)(handleScrollY(this.lastScrollTop, this.treeType, onBodyScroll), 300); (0, _utils.debounce)(handleScrollY(this.lastScrollTop, this.treeType, onBodyScroll), 300);
} else {
//滚动回调
onBodyScroll(this.lastScrollTop);
} }
} }

View File

@ -55,7 +55,7 @@ const data = [ ...new Array(10000) ].map((e, i) => {
}) })
class Demo32 extends Component { class Demo43 extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -87,4 +87,4 @@ class Demo32 extends Component {
} }
} }
export default Demo32; export default Demo43;

File diff suppressed because one or more lines are too long

53
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -664,11 +664,15 @@ class Table extends Component {
targetIndex = i; targetIndex = i;
} }
}); });
if(currentIndex > -1) {
data = this.swapArray(data,currentIndex,targetIndex); data = this.swapArray(data,currentIndex,targetIndex);
this.props.onDropRow && this.props.onDropRow(data,record); this.props.onDropRow && this.props.onDropRow(data,record,targetIndex);
this.setState({ this.setState({
data, data,
}); });
} else {
this.props.onDropRow && this.props.onDropRow(data,record,targetIndex);
}
} }
/** /**
* 数组元素交换位置 * 数组元素交换位置