Skip to content

Commit a390b2a

Browse files
RoosDanielwuweiweiwu
authored andcommitted
Split Table._setScrollbarWidth by adding public function Table.getScrollbarWidth (bvaughn#1411)
* Create public method Table.getScrollbarWidth * Add documentation for Table.getScrollbarWidth
1 parent 3ac20f5 commit a390b2a

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

docs/Table.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ This may be appropriate if the underlying row data has changed but the row sizes
6161

6262
Gets offset for a given row and alignment.
6363

64+
##### getScrollbarWidth
65+
66+
Gets the scrollbar width used to pad the table-header.
67+
6468
##### measureAllRows
6569
Pre-measure all rows in a `Table`.
6670

source/Table/Table.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ export default class Table extends React.PureComponent {
337337
}
338338
}
339339

340+
getScrollbarWidth() {
341+
if (this.Grid) {
342+
const Grid = findDOMNode(this.Grid);
343+
const clientWidth = Grid.clientWidth || 0;
344+
const offsetWidth = Grid.offsetWidth || 0;
345+
return offsetWidth - clientWidth;
346+
}
347+
348+
return 0;
349+
}
350+
340351
componentDidMount() {
341352
this._setScrollbarWidth();
342353
}
@@ -726,13 +737,8 @@ export default class Table extends React.PureComponent {
726737
}
727738

728739
_setScrollbarWidth() {
729-
if (this.Grid) {
730-
const Grid = findDOMNode(this.Grid);
731-
const clientWidth = Grid.clientWidth || 0;
732-
const offsetWidth = Grid.offsetWidth || 0;
733-
const scrollbarWidth = offsetWidth - clientWidth;
740+
const scrollbarWidth = this.getScrollbarWidth();
734741

735-
this.setState({scrollbarWidth});
736-
}
742+
this.setState({scrollbarWidth});
737743
}
738744
}

0 commit comments

Comments
 (0)