Skip to content

Commit

Permalink
Split Table._setScrollbarWidth by adding public function Table.getScr…
Browse files Browse the repository at this point in the history
…ollbarWidth (#1411)

* Create public method Table.getScrollbarWidth

* Add documentation for Table.getScrollbarWidth
  • Loading branch information
RoosDaniel authored and wuweiweiwu committed Sep 5, 2019
1 parent 3ac20f5 commit a390b2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/Table.md
Expand Up @@ -61,6 +61,10 @@ This may be appropriate if the underlying row data has changed but the row sizes

Gets offset for a given row and alignment.

##### getScrollbarWidth

Gets the scrollbar width used to pad the table-header.

##### measureAllRows
Pre-measure all rows in a `Table`.

Expand Down
20 changes: 13 additions & 7 deletions source/Table/Table.js
Expand Up @@ -337,6 +337,17 @@ export default class Table extends React.PureComponent {
}
}

getScrollbarWidth() {
if (this.Grid) {
const Grid = findDOMNode(this.Grid);
const clientWidth = Grid.clientWidth || 0;
const offsetWidth = Grid.offsetWidth || 0;
return offsetWidth - clientWidth;
}

return 0;
}

componentDidMount() {
this._setScrollbarWidth();
}
Expand Down Expand Up @@ -726,13 +737,8 @@ export default class Table extends React.PureComponent {
}

_setScrollbarWidth() {
if (this.Grid) {
const Grid = findDOMNode(this.Grid);
const clientWidth = Grid.clientWidth || 0;
const offsetWidth = Grid.offsetWidth || 0;
const scrollbarWidth = offsetWidth - clientWidth;
const scrollbarWidth = this.getScrollbarWidth();

this.setState({scrollbarWidth});
}
this.setState({scrollbarWidth});
}
}

0 comments on commit a390b2a

Please sign in to comment.