fix: reset scrollbar when the whole width changes

This commit is contained in:
gx 2021-03-16 14:12:35 +08:00
parent d6e16c2ef1
commit b0914c928e
5 changed files with 20 additions and 23 deletions

View File

@ -1245,12 +1245,10 @@ var Table = function (_Component) {
// bodyStyle.height = bodyStyle.height || scroll.y;
innerBodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;
innerBodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
if (scroll.x) {
if (this.computeWidth > this.contentDomWidth) {
innerBodyStyle.overflowX = 'scroll';
} else {
innerBodyStyle.overflowX = 'hidden';
}
if (this.computeWidth > this.contentDomWidth) {
innerBodyStyle.overflowX = 'scroll';
} else {
innerBodyStyle.overflowX = 'hidden';
}
} else {
bodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;

19
dist/demo.js vendored
View File

@ -48307,6 +48307,7 @@
_this.leftColumnsLength; //左侧固定列的长度
_this.centerColumnsLength; //非固定列的长度
_this.columnsChildrenList = []; //复杂表头、所有叶子节点
_this.dataChanged = false; // 数据是否改变
return _this;
}
@ -48341,6 +48342,7 @@
showRowNum = _props.showRowNum;
if ('data' in nextProps) {
this.dataChanged = JSON.stringify(this.props.data) !== JSON.stringify(nextProps.data);
this.setState({
data: nextProps.data
});
@ -48901,7 +48903,7 @@
var record = data[i];
var key = this.getRowKey(record, i);
// 兼容 NCC 以前的业务逻辑,支持外部通过 record 中的 isleaf 字段,判断是否为叶子节点
record['_isLeaf'] = typeof record['isleaf'] === 'boolean' ? record['isleaf'] : record['_isLeaf'];
typeof record['isleaf'] === 'boolean' && (record['_isLeaf'] = record['isleaf']);
// _isLeaf 字段是在 bigData 里添加的,只有层级树大数据场景需要该字段
// _isLeaf 有三种取值情况true / false / null。Table内部字段
var _isLeaf = typeof record['_isLeaf'] === 'boolean' ? record['_isLeaf'] : null;
@ -49152,12 +49154,10 @@
// bodyStyle.height = bodyStyle.height || scroll.y;
innerBodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;
innerBodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
if (scroll.x) {
if (this.computeWidth > this.contentDomWidth) {
innerBodyStyle.overflowX = 'scroll';
} else {
innerBodyStyle.overflowX = 'hidden';
}
if (this.computeWidth > this.contentDomWidth) {
innerBodyStyle.overflowX = 'scroll';
} else {
innerBodyStyle.overflowX = 'hidden';
}
} else {
bodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;
@ -49421,8 +49421,9 @@
var headRows = this.headTable ? this.headTable.querySelectorAll('thead') : this.bodyTable.querySelectorAll('thead');
var expandedRows = this.bodyTable.querySelectorAll('.' + clsPrefix + '-expanded-row') || [];
var bodyRows = this.bodyTable.querySelectorAll('.' + clsPrefix + '-row') || [];
var leftBodyRows = this.refs.fixedColumnsBodyLeft && this.refs.fixedColumnsBodyLeft.querySelectorAll('.' + clsPrefix + '-row') || [];
var rightBodyRows = this.refs.fixedColumnsBodyRight && this.refs.fixedColumnsBodyRight.querySelectorAll('.' + clsPrefix + '-row') || [];
var leftBodyRows = !this.dataChanged && this.refs.fixedColumnsBodyLeft && this.refs.fixedColumnsBodyLeft.querySelectorAll('.' + clsPrefix + '-row') || [];
var rightBodyRows = !this.dataChanged && this.refs.fixedColumnsBodyRight && this.refs.fixedColumnsBodyRight.querySelectorAll('.' + clsPrefix + '-row') || [];
this.dataChanged = false;
var fixedColumnsHeadRowsHeight = [].map.call(headRows, function (row) {
var height = headerHeight;
if (headerHeight) {

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "bee-table",
"version": "2.3.15-beta.9",
"version": "2.3.15-beta.10",
"description": "Table ui component for react",
"keywords": [
"react",

View File

@ -1043,12 +1043,10 @@ class Table extends Component {
// bodyStyle.height = bodyStyle.height || scroll.y;
innerBodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;
innerBodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
if (scroll.x) {
if (this.computeWidth > this.contentDomWidth) {
innerBodyStyle.overflowX = 'scroll';
} else {
innerBodyStyle.overflowX = 'hidden';
}
if (this.computeWidth > this.contentDomWidth) {
innerBodyStyle.overflowX = 'scroll';
} else {
innerBodyStyle.overflowX = 'hidden';
}
} else {
bodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;