Fix rendering issue on iOS

iOS sets both window.outerHeight/outerWith to 0, which messes with the
grid dimension calculations.
This commit is contained in:
2019-03-26 22:15:56 -07:00
parent dd784df708
commit f924c4401e
3 changed files with 145 additions and 32 deletions

View File

@@ -21,16 +21,22 @@ export class Root extends React.PureComponent<Props, State> {
// innerWidth gets messed up when rotating phones from landscape -> portrait,
// and chrome seems to not report innerWidth correctly when scrollbars are present
private _viewWidth = () =>
Math.min(
private _viewWidth = (): number => {
// iOS Safari does not set outerWidth/outerHeight
if (!window.outerWidth) {
return window.innerWidth;
}
return Math.min(
window.innerWidth,
window.outerWidth,
document.getElementById("mount")!.clientWidth
);
}
state: State = {
gridHeights: [],
pageBottom: window.outerHeight + window.pageYOffset,
pageBottom: window.innerHeight + window.pageYOffset,
width: this._viewWidth()
};
@@ -103,7 +109,7 @@ export class Root extends React.PureComponent<Props, State> {
private _onViewChange = () => {
this.setState({
pageBottom: window.outerHeight + window.pageYOffset,
pageBottom: window.innerHeight + window.pageYOffset,
width: this._viewWidth()
});
};