’动态添加列后、固定列和普通table错位问题‘

This commit is contained in:
wanghaoo 2018-10-25 09:50:58 +08:00
parent 46ccf18832
commit 7315c22181
3 changed files with 14 additions and 6 deletions

8
dist/demo.js vendored
View File

@ -10805,8 +10805,7 @@
if (nextProps.columns && nextProps.columns !== this.props.columns) {
this.columnManager.reset(nextProps.columns);
if (nextProps.columns.length !== this.props.columns.length && this.refs && this.refs.bodyTable) {
this.refs.fixedColumnsBodyLeft && (this.refs.fixedColumnsBodyLeft.scrollTop = this.refs.bodyTable.scrollTop);
this.refs.fixedColumnsBodyRight && (this.refs.fixedColumnsBodyRight.scrollTop = this.refs.bodyTable.scrollTop);
this.scrollTop = this.refs.bodyTable.scrollTop;
}
} else if (nextProps.children !== this.props.children) {
this.columnManager.reset(null, nextProps.children);
@ -10825,6 +10824,11 @@
if (typeof this.props.scroll.x !== 'number' && this.contentTable.getBoundingClientRect().width !== this.contentDomWidth) {
this.computeTableWidth();
}
if (this.scrollTop) {
this.refs.fixedColumnsBodyLeft && (this.refs.fixedColumnsBodyLeft.scrollTop = this.scrollTop);
this.refs.fixedColumnsBodyRight && (this.refs.fixedColumnsBodyRight.scrollTop = this.scrollTop);
this.scrollTop = 0;
}
};
Table.prototype.componentWillUnmount = function componentWillUnmount() {

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -158,9 +158,8 @@ class Table extends Component {
if (nextProps.columns && nextProps.columns !== this.props.columns) {
this.columnManager.reset(nextProps.columns);
if(nextProps.columns.length !== this.props.columns.length && this.refs && this.refs.bodyTable){
this.refs.fixedColumnsBodyLeft && ( this.refs.fixedColumnsBodyLeft.scrollTop = this.refs.bodyTable.scrollTop);
this.refs.fixedColumnsBodyRight && ( this.refs.fixedColumnsBodyRight.scrollTop = this.refs.bodyTable.scrollTop);
}
this.scrollTop = this.refs.bodyTable.scrollTop;
}
} else if (nextProps.children !== this.props.children) {
this.columnManager.reset(null, nextProps.children);
@ -180,6 +179,11 @@ class Table extends Component {
if (typeof (this.props.scroll.x) !== 'number' && this.contentTable.getBoundingClientRect().width !== this.contentDomWidth) {
this.computeTableWidth();
}
if(this.scrollTop){
this.refs.fixedColumnsBodyLeft && ( this.refs.fixedColumnsBodyLeft.scrollTop = this.scrollTop);
this.refs.fixedColumnsBodyRight && ( this.refs.fixedColumnsBodyRight.scrollTop = this.scrollTop);
this.scrollTop = 0;
}
}