This commit is contained in:
wanghaoo 2018-12-26 14:26:42 +08:00
parent 062ec94019
commit 96aade8948
10 changed files with 15556 additions and 61 deletions

View File

@ -124,12 +124,12 @@ function bigData(Table) {
this.handleScroll = function (nextScrollTop) {
var _this = _this3;
var _this$props = _this.props,
data = _this$props.data,
height = _this$props.height,
_this$props$scroll = _this$props.scroll,
scroll = _this$props$scroll === undefined ? {} : _this$props$scroll;
scroll = _this$props$scroll === undefined ? {} : _this$props$scroll,
loadBuffer = _this$props.loadBuffer;
var rowHeight = height ? height : defaultHeight;
var _this$currentIndex = _this.currentIndex,
@ -195,7 +195,7 @@ function bigData(Table) {
// 向下滚动 下临界值超出缓存的endIndex则重新渲染
if (rowsInView + index > endIndex - rowDiff && isOrder) {
_this3.startIndex = index;
_this3.startIndex = index - loadBuffer;
endIndex = _this3.startIndex + loadCount;
if (endIndex > data.length) {
endIndex = data.length;
@ -205,7 +205,7 @@ function bigData(Table) {
}
// 向上滚动当前的index是否已经加载currentIndex若干上临界值小于startIndex则重新渲染
if (!isOrder && index < startIndex + rowDiff) {
startIndex = index - parseInt(_this3.loadCount / 2); //有时会是小数问题所以parseInt转换下
startIndex = index - loadBuffer;
if (startIndex < 0) {
startIndex = 0;
}

View File

@ -85,8 +85,9 @@ class Demo31 extends Component {
return (
<Table
columns={innerColumns}
style={{height:height}}
// style={{height:height}}
data={this.state.data_obj[record.key]}
/>
@ -130,7 +131,7 @@ class Demo31 extends Component {
onExpand={this.getData}
expandedRowRender={this.expandedRowRender}
scroll={{y:350}}
defaultExpandedRowKeys={[0,1]}
// defaultExpandedRowKeys={[0,1]}
title={currentData => <div>标题: 这是一个标题</div>}
footer={currentData => <div>表尾: 我是小尾巴</div>}
/>

File diff suppressed because one or more lines are too long

12
dist/demo.css vendored
View File

@ -10322,5 +10322,17 @@ li.rc-time-picker-panel-select-option-disabled:hover {
.demo25 .u-table-filter-column-filter-icon {
right: 15px; }
th .drop-menu .uf {
font-size: 12px;
visibility: hidden;
margin-left: 15px; }
th:hover .uf {
visibility: visible; }
.demo3 .u-table-thead th {
padding-top: 0px;
padding-bottom: 0px; }
/*# sourceMappingURL=demo.css.map */

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

15571
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

@ -508,7 +508,7 @@ class Table extends Component {
let expandedRowContent;
if (expandedRowRender && isRowExpanded) {
expandedRowContent = expandedRowRender(record, i, indent);
expandedContentHeight = parseInt(expandedRowContent.props.style?expandedRowContent.props.style.height:0);
expandedContentHeight = parseInt(expandedRowContent.props.style && expandedRowContent.props.style.height?expandedRowContent.props.style.height:0);
}
//只有当使用expandedRowRender参数的时候才去识别isHiddenExpandIcon隐藏行展开的icon
if (expandedRowRender && typeof props.haveExpandIcon == 'function') {
@ -985,10 +985,9 @@ class Table extends Component {
}
this.lastScrollTop = e.target.scrollTop;
if(handleScroll){
const scrollTop = e.target.scrollTop
debounce(
handleScroll(scrollTop)
,200);
handleScroll(this.lastScrollTop)
,500);
}
}

View File

@ -85,7 +85,7 @@ class TableRow extends Component{
setRowHeight() {
const { setRowHeight , expandedContentHeight,lazyCurrentIndex=0,fixed} = this.props
const { setRowHeight , expandedContentHeight=0,lazyCurrentIndex=0,fixed} = this.props
if (!setRowHeight || !this.element || fixed) return
setRowHeight(this.element.clientHeight + expandedContentHeight, this.props.index+lazyCurrentIndex)
}

View File

@ -58,7 +58,7 @@ export default function bigData(Table) {
*/
handleScroll = (nextScrollTop)=> {
const _this = this;
const {data,height,scroll={}} = _this.props;
const {data,height,scroll={},loadBuffer} = _this.props;
const rowHeight = height?height:defaultHeight;
const {currentIndex = 0 ,loadCount,scrollTop,currentScrollTop} = _this;
let {endIndex,startIndex} = _this;
@ -117,7 +117,7 @@ handleScroll = (nextScrollTop)=> {
// 向下滚动 下临界值超出缓存的endIndex则重新渲染
if(rowsInView+index > endIndex - rowDiff && isOrder){
this.startIndex = index;
this.startIndex = index - loadBuffer;
endIndex = this.startIndex + loadCount
if(endIndex > data.length){
endIndex = data.length
@ -127,7 +127,7 @@ handleScroll = (nextScrollTop)=> {
}
// 向上滚动当前的index是否已经加载currentIndex若干上临界值小于startIndex则重新渲染
if(!isOrder && index < startIndex + rowDiff){
startIndex = index - parseInt(this.loadCount/2);//有时会是小数问题所以parseInt转换下
startIndex = index - loadBuffer;
if(startIndex<0){
startIndex = 0;
}