fix: 修改触发onScroll事件的元素层级

This commit is contained in:
gx 2021-02-24 16:53:37 +08:00
parent 7c71bcf6eb
commit d867fdff33
1 changed files with 22 additions and 8 deletions

View File

@ -285,6 +285,20 @@ class Table extends Component {
} }
// 是否传入 scroll中的y属性如果传入判断是否是整数如果是则进行比较 。bodyTable 的clientHeight进行判断 // 是否传入 scroll中的y属性如果传入判断是否是整数如果是则进行比较 。bodyTable 的clientHeight进行判断
this.isShowScrollY(); 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() { componentWillUnmount() {
@ -1093,7 +1107,6 @@ class Table extends Component {
}; };
let headTable; let headTable;
if (useFixedHeader) { if (useFixedHeader) {
headTable = ( headTable = (
<div <div
@ -1112,14 +1125,15 @@ class Table extends Component {
<div <div
className={`${clsPrefix}-body`} className={`${clsPrefix}-body`}
style={bodyStyle} style={bodyStyle}
ref={(el)=>{this.bodyTable = el}}
onMouseOver={this.detectScrollTarget} onMouseOver={this.detectScrollTarget}
onTouchStart={this.detectScrollTarget} onTouchStart={this.detectScrollTarget}
onScroll={this.handleBodyScroll} ref={(el)=>{this.bodyTableOuter = el}}
onMouseLeave={this.onBodyMouseLeave} onMouseLeave={this.onBodyMouseLeave}
> >
{this.renderDragHideTable()} {this.renderDragHideTable()}
{renderTable(!useFixedHeader)} <div className="scroll-container" onScroll={this.handleBodyScroll} ref={(el)=>{this.bodyTable = el}} style={{...bodyStyle}}>
{renderTable(!useFixedHeader)}
</div>
</div> </div>
); );
@ -1140,13 +1154,13 @@ class Table extends Component {
<div <div
style={{...innerBodyStyle}} style={{...innerBodyStyle}}
className={`${clsPrefix}-body-inner`} className={`${clsPrefix}-body-inner`}
ref={refName} ref={el => this[`${refName}Outer`] = el}
onMouseOver={this.detectScrollTarget} onMouseOver={this.detectScrollTarget}
onTouchStart={this.detectScrollTarget} onTouchStart={this.detectScrollTarget}
onScroll={this.handleBodyScroll}
> >
{renderTable(!useFixedHeader)} <div className="fixed-scroll-container" ref={refName} style={{...innerBodyStyle}} onScroll={this.handleBodyScroll}>
{/* <div className="scroll-dom" style={{height:`${this.scrollbarWidth}px`}}></div> */} {renderTable(!useFixedHeader)}
</div>
</div> </div>
</div> </div>
); );