滚动加载data长度改变时优化endIndex计算
This commit is contained in:
parent
2ef7e05d90
commit
887f43fd47
|
@ -81,14 +81,11 @@ function bigData(Table) {
|
|||
_this.currentIndex = 0;
|
||||
_this.startIndex = _this.currentIndex; //数据开始位置
|
||||
_this.endIndex = _this.currentIndex + _this.loadCount; //数据结束位置
|
||||
if (_this.endIndex > dataLen) {
|
||||
_this.endIndex = dataLen;
|
||||
}
|
||||
}
|
||||
if (nextProps.data !== props.data) {
|
||||
_this.computeCachedRowParentIndex(nextProps.data);
|
||||
if (nextProps.data.length > 0 && _this.endIndex < 1) {
|
||||
_this.endIndex = _this.currentIndex + _this.loadCount; //数据结束位置
|
||||
if (nextProps.data.length > 0) {
|
||||
_this.endIndex = _this.currentIndex - this.loadBuffer + _this.loadCount; //数据结束位置
|
||||
}
|
||||
}
|
||||
//如果传currentIndex,会判断该条数据是否在可视区域,如果没有的话,则重新计算startIndex和endIndex
|
||||
|
@ -272,6 +269,15 @@ function bigData(Table) {
|
|||
var endIndex = this.endIndex,
|
||||
startIndex = this.startIndex;
|
||||
|
||||
if (startIndex < 0) {
|
||||
startIndex = 0;
|
||||
}
|
||||
if (endIndex < 0) {
|
||||
endIndex = 0;
|
||||
}
|
||||
if (endIndex > data.length) {
|
||||
endIndex = data.length;
|
||||
}
|
||||
var lazyLoad = {
|
||||
startIndex: startIndex,
|
||||
startParentIndex: startIndex //为树状节点做准备
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bee-table",
|
||||
"version": "1.6.39",
|
||||
"version": "1.6.40-beta.2",
|
||||
"description": "Table ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
|
|
@ -62,16 +62,14 @@ export default function bigData(Table) {
|
|||
if (nextProps.data !== props.data) {
|
||||
_this.computeCachedRowParentIndex(nextProps.data);
|
||||
if(nextProps.data.length>0){
|
||||
_this.endIndex = _this.startIndex + _this.loadCount; //数据结束位置
|
||||
_this.endIndex = _this.currentIndex - nextProps.loadBuffer + _this.loadCount; //数据结束位置
|
||||
}
|
||||
}
|
||||
//如果传currentIndex,会判断该条数据是否在可视区域,如果没有的话,则重新计算startIndex和endIndex
|
||||
if(currentIndex!==-1 && currentIndex !== this.currentIndex){
|
||||
_this.setStartAndEndIndex(currentIndex,dataLen);
|
||||
}
|
||||
if(_this.endIndex > dataLen){
|
||||
_this.endIndex = dataLen;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -429,7 +427,16 @@ export default function bigData(Table) {
|
|||
render() {
|
||||
const { data } = this.props;
|
||||
const { scrollTop } = this;
|
||||
const { endIndex, startIndex } = this;
|
||||
let { endIndex, startIndex } = this;
|
||||
if(startIndex < 0){
|
||||
startIndex = 0;
|
||||
}
|
||||
if(endIndex < 0 ){
|
||||
endIndex = 0;
|
||||
}
|
||||
if(endIndex > data.length){
|
||||
endIndex = data.length;
|
||||
}
|
||||
const lazyLoad = {
|
||||
startIndex: startIndex,
|
||||
startParentIndex: startIndex //为树状节点做准备
|
||||
|
|
Loading…
Reference in New Issue