Ensure horizontal scrollbar is not shown

This commit is contained in:
Jordan Eldredge 2018-12-14 13:06:49 -08:00
parent 8d914b8eb5
commit 8e76eb9faa
2 changed files with 12 additions and 6 deletions

View file

@ -36,8 +36,13 @@ class SkinTable extends React.Component {
}
_handleResize() {
// TODO: Try to recompute the scroll position
this.setState(Utils.getWindowSize());
const { windowWidth, windowHeight } = Utils.getWindowSize();
if (
windowWidth != this.state.windowWidth ||
windowHeight != this.state.windowHeight
) {
this.setState({ windowWidth, windowHeight });
}
const { rowHeight, columnWidth } = this._getTableDimensions();
this.props.setCellSize({ rowHeight, columnWidth });
}
@ -45,8 +50,9 @@ class SkinTable extends React.Component {
componentDidMount() {
window.addEventListener("scroll", this._handleScroll);
window.addEventListener("resize", this._handleResize);
const { rowHeight, columnWidth } = this._getTableDimensions();
this.props.setCellSize({ rowHeight, columnWidth });
// Our initial render may have caused the scrollbar to appear. So we
// remeasure.
this._handleResize();
}
componentWillUnmount() {

View file

@ -21,8 +21,8 @@ export function getWindowSize() {
d = document,
e = d.documentElement,
g = d.getElementsByTagName("body")[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight || g.clientHeight;
x = e.clientWidth || g.clientWidth || w.innerWidth,
y = e.clientHeight || g.clientHeight || w.innerHeight;
return {
windowWidth: x,