fix(scroll为y时宽度计算问题bug):

This commit is contained in:
wanghaoo 2018-11-08 17:55:09 +08:00
parent 2ecdcf74e4
commit c5789893cf
2 changed files with 7 additions and 3 deletions

View File

@ -211,6 +211,10 @@ var Table = function (_Component) {
Table.prototype.componentDidMount = function componentDidMount() { Table.prototype.componentDidMount = function componentDidMount() {
setTimeout(this.resetScrollY, 300); setTimeout(this.resetScrollY, 300);
//含有纵向滚动条
if (this.props.scroll.y) {
this.scrollbarWidth = (0, _utils.measureScrollbar)();
}
//后续也放在recevice里面 //后续也放在recevice里面
if (!this.props.originWidth) { if (!this.props.originWidth) {
this.computeTableWidth(); this.computeTableWidth();
@ -290,7 +294,7 @@ var Table = function (_Component) {
var lastShowIndex = computeObj.lastShowIndex; var lastShowIndex = computeObj.lastShowIndex;
this.computeWidth = computeObj.computeWidth; this.computeWidth = computeObj.computeWidth;
if (this.computeWidth < this.contentWidth) { if (this.computeWidth < this.contentWidth) {
var contentWidthDiff = this.contentWidth - this.computeWidth; var contentWidthDiff = this.scrollbarWidth ? this.contentWidth - this.computeWidth - this.scrollbarWidth : this.contentWidth - this.computeWidth;
this.setState({ contentWidthDiff: contentWidthDiff, lastShowIndex: lastShowIndex }); this.setState({ contentWidthDiff: contentWidthDiff, lastShowIndex: lastShowIndex });
} else { } else {
this.contentWidth = this.computeWidth; this.contentWidth = this.computeWidth;
@ -740,7 +744,7 @@ var Table = function (_Component) {
useFixedHeader = true; useFixedHeader = true;
// Add negative margin bottom for scroll bar overflow bug // Add negative margin bottom for scroll bar overflow bug
var scrollbarWidth = (0, _utils.measureScrollbar)(); var scrollbarWidth = this.scrollbarWidth;
if (scrollbarWidth >= 0) { if (scrollbarWidth >= 0) {
(fixed ? bodyStyle : headStyle).paddingBottom = '0px'; (fixed ? bodyStyle : headStyle).paddingBottom = '0px';
//显示表头滚动条 //显示表头滚动条

View File

@ -1,6 +1,6 @@
{ {
"name": "bee-table", "name": "bee-table",
"version": "1.4.35", "version": "1.4.36",
"description": "Table ui component for react", "description": "Table ui component for react",
"keywords": [ "keywords": [
"react", "react",