fix(滚动加载下currentIndex设置bug,支持添加到第一条):
This commit is contained in:
parent
b465c43173
commit
823c7849a1
|
@ -283,7 +283,7 @@ var Table = function (_Component) {
|
||||||
this.columnManager.reset(null, nextProps.children);
|
this.columnManager.reset(null, nextProps.children);
|
||||||
}
|
}
|
||||||
//适配lazyload
|
//适配lazyload
|
||||||
if (nextProps.scrollTop) {
|
if (nextProps.scrollTop > -1) {
|
||||||
// this.refs.bodyTable.scrollTop = nextProps.scrollTop;
|
// this.refs.bodyTable.scrollTop = nextProps.scrollTop;
|
||||||
this.scrollTop = nextProps.scrollTop;
|
this.scrollTop = nextProps.scrollTop;
|
||||||
}
|
}
|
||||||
|
@ -305,11 +305,11 @@ var Table = function (_Component) {
|
||||||
this.computeTableWidth();
|
this.computeTableWidth();
|
||||||
this.firstDid = false; //避免重复update
|
this.firstDid = false; //避免重复update
|
||||||
}
|
}
|
||||||
if (this.scrollTop) {
|
if (this.scrollTop > -1) {
|
||||||
this.refs.fixedColumnsBodyLeft && (this.refs.fixedColumnsBodyLeft.scrollTop = this.scrollTop);
|
this.refs.fixedColumnsBodyLeft && (this.refs.fixedColumnsBodyLeft.scrollTop = this.scrollTop);
|
||||||
this.refs.fixedColumnsBodyRight && (this.refs.fixedColumnsBodyRight.scrollTop = this.scrollTop);
|
this.refs.fixedColumnsBodyRight && (this.refs.fixedColumnsBodyRight.scrollTop = this.scrollTop);
|
||||||
this.refs.bodyTable.scrollTop = this.scrollTop;
|
this.refs.bodyTable.scrollTop = this.scrollTop;
|
||||||
this.scrollTop = 0;
|
this.scrollTop = -1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
||||||
|
|
||||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
|
||||||
|
|
||||||
var defaultHeight = 40;
|
var defaultHeight = 30;
|
||||||
var rowDiff = 3; //行差值
|
var rowDiff = 3; //行差值
|
||||||
var treeTypeIndex = 0;
|
var treeTypeIndex = 0;
|
||||||
function bigData(Table) {
|
function bigData(Table) {
|
||||||
|
@ -108,7 +108,7 @@ function bigData(Table) {
|
||||||
|
|
||||||
BigData.prototype.setStartAndEndIndex = function setStartAndEndIndex(currentIndex, dataLen) {
|
BigData.prototype.setStartAndEndIndex = function setStartAndEndIndex(currentIndex, dataLen) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
if (currentIndex > _this.endIndex) {
|
if (currentIndex > _this.currentIndex + _this.props.rowsInView) {
|
||||||
_this.currentIndex = currentIndex;
|
_this.currentIndex = currentIndex;
|
||||||
_this.endIndex = _this.currentIndex; //数据开始位置
|
_this.endIndex = _this.currentIndex; //数据开始位置
|
||||||
_this.startIndex = _this.currentIndex - _this.loadCount; //数据结束位置
|
_this.startIndex = _this.currentIndex - _this.loadCount; //数据结束位置
|
||||||
|
@ -118,7 +118,9 @@ function bigData(Table) {
|
||||||
if (_this.startIndex < 0) {
|
if (_this.startIndex < 0) {
|
||||||
_this.startIndex = 0;
|
_this.startIndex = 0;
|
||||||
}
|
}
|
||||||
} else if (currentIndex < _this.startIndex) {
|
//重新设定scrollTop值
|
||||||
|
_this.scrollTop = _this.getSumHeight(0, _this.endIndex - _this.rowsInView + 2);
|
||||||
|
} else if (currentIndex < _this.currentIndex) {
|
||||||
_this.currentIndex = currentIndex;
|
_this.currentIndex = currentIndex;
|
||||||
_this.startIndex = currentIndex;
|
_this.startIndex = currentIndex;
|
||||||
_this.endIndex = currentIndex + _this.loadCount;
|
_this.endIndex = currentIndex + _this.loadCount;
|
||||||
|
@ -128,9 +130,9 @@ function bigData(Table) {
|
||||||
if (_this.startIndex < 0) {
|
if (_this.startIndex < 0) {
|
||||||
_this.startIndex = 0;
|
_this.startIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//重新设定scrollTop值
|
//重新设定scrollTop值
|
||||||
_this.scrollTop = _this.getSumHeight(0, _this.endIndex - _this.rowsInView + 2);
|
_this.scrollTop = _this.getSumHeight(0, _this.startIndex);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BigData.prototype.getRowKey = function getRowKey(record, index) {
|
BigData.prototype.getRowKey = function getRowKey(record, index) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bee-table",
|
"name": "bee-table",
|
||||||
"version": "1.6.34",
|
"version": "1.6.35",
|
||||||
"description": "Table ui component for react",
|
"description": "Table ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
|
|
Loading…
Reference in New Issue