From d867fdff334715863a08bd9dd7f51ef23420259d Mon Sep 17 00:00:00 2001 From: gx Date: Wed, 24 Feb 2021 16:53:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=A7=A6=E5=8F=91onSc?= =?UTF-8?q?roll=E4=BA=8B=E4=BB=B6=E7=9A=84=E5=85=83=E7=B4=A0=E5=B1=82?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Table.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Table.js b/src/Table.js index 25c9cdc..dcc1caa 100644 --- a/src/Table.js +++ b/src/Table.js @@ -285,6 +285,20 @@ class Table extends Component { } // 是否传入 scroll中的y属性,如果传入判断是否是整数,如果是则进行比较 。bodyTable 的clientHeight进行判断 this.isShowScrollY(); + if (this.bodyTable) { + if (!this.props.scroll.x && window.getComputedStyle(this.bodyTable).overflowX !== 'hidden') { + this.bodyTable.style.overflowX = 'hidden' + } + } + if (this.bodyTableOuter) { // 隐藏几个不需要真正滚动的父元素的滚动条 + this.bodyTableOuter.style.overflowY = 'hidden' + } + if (this.fixedColumnsBodyLeftOuter) { + this.fixedColumnsBodyLeftOuter.style.overflowY = 'hidden' + } + if (this.fixedColumnsBodyRightOuter) { + this.fixedColumnsBodyRightOuter.style.overflowY = 'hidden' + } } componentWillUnmount() { @@ -1093,7 +1107,6 @@ class Table extends Component { }; let headTable; - if (useFixedHeader) { headTable = (
{this.bodyTable = el}} onMouseOver={this.detectScrollTarget} onTouchStart={this.detectScrollTarget} - onScroll={this.handleBodyScroll} + ref={(el)=>{this.bodyTableOuter = el}} onMouseLeave={this.onBodyMouseLeave} > {this.renderDragHideTable()} - {renderTable(!useFixedHeader)} +
{this.bodyTable = el}} style={{...bodyStyle}}> + {renderTable(!useFixedHeader)} +
); @@ -1140,13 +1154,13 @@ class Table extends Component {
this[`${refName}Outer`] = el} onMouseOver={this.detectScrollTarget} onTouchStart={this.detectScrollTarget} - onScroll={this.handleBodyScroll} > - {renderTable(!useFixedHeader)} - {/*
*/} +
+ {renderTable(!useFixedHeader)} +
);