From 823c7849a11a7e6e4cd02fd4d7676612b809ff6b Mon Sep 17 00:00:00 2001 From: wanghaoo Date: Fri, 25 Jan 2019 11:26:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=BB=9A=E5=8A=A8=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=B8=8BcurrentIndex=E8=AE=BE=E7=BD=AEbug,=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=B0=E7=AC=AC=E4=B8=80=E6=9D=A1):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/Table.js | 6 +++--- build/lib/bigData.js | 12 +++++++----- package.json | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/build/Table.js b/build/Table.js index 73f81ff..a1a3d10 100644 --- a/build/Table.js +++ b/build/Table.js @@ -283,7 +283,7 @@ var Table = function (_Component) { this.columnManager.reset(null, nextProps.children); } //适配lazyload - if (nextProps.scrollTop) { + if (nextProps.scrollTop > -1) { // this.refs.bodyTable.scrollTop = nextProps.scrollTop; this.scrollTop = nextProps.scrollTop; } @@ -305,11 +305,11 @@ var Table = function (_Component) { this.computeTableWidth(); this.firstDid = false; //避免重复update } - if (this.scrollTop) { + if (this.scrollTop > -1) { this.refs.fixedColumnsBodyLeft && (this.refs.fixedColumnsBodyLeft.scrollTop = this.scrollTop); this.refs.fixedColumnsBodyRight && (this.refs.fixedColumnsBodyRight.scrollTop = this.scrollTop); this.refs.bodyTable.scrollTop = this.scrollTop; - this.scrollTop = 0; + this.scrollTop = -1; } }; diff --git a/build/lib/bigData.js b/build/lib/bigData.js index 7550068..b8ed836 100644 --- a/build/lib/bigData.js +++ b/build/lib/bigData.js @@ -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); } -var defaultHeight = 40; +var defaultHeight = 30; var rowDiff = 3; //行差值 var treeTypeIndex = 0; function bigData(Table) { @@ -108,7 +108,7 @@ function bigData(Table) { BigData.prototype.setStartAndEndIndex = function setStartAndEndIndex(currentIndex, dataLen) { var _this = this; - if (currentIndex > _this.endIndex) { + if (currentIndex > _this.currentIndex + _this.props.rowsInView) { _this.currentIndex = currentIndex; _this.endIndex = _this.currentIndex; //数据开始位置 _this.startIndex = _this.currentIndex - _this.loadCount; //数据结束位置 @@ -118,7 +118,9 @@ function bigData(Table) { if (_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.startIndex = currentIndex; _this.endIndex = currentIndex + _this.loadCount; @@ -128,9 +130,9 @@ function bigData(Table) { if (_this.startIndex < 0) { _this.startIndex = 0; } + //重新设定scrollTop值 + _this.scrollTop = _this.getSumHeight(0, _this.startIndex); } - //重新设定scrollTop值 - _this.scrollTop = _this.getSumHeight(0, _this.endIndex - _this.rowsInView + 2); }; BigData.prototype.getRowKey = function getRowKey(record, index) { diff --git a/package.json b/package.json index bf5ef96..b2fcc2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bee-table", - "version": "1.6.34", + "version": "1.6.35", "description": "Table ui component for react", "keywords": [ "react",