From 301d712763c99ad43ab12400960cc8e75e573b4b Mon Sep 17 00:00:00 2001 From: Aaron Gutierrez Date: Wed, 19 Jan 2022 21:16:09 -0700 Subject: [PATCH] and some more --- src/components/big_picture.tsx | 3 +-- src/components/grid.tsx | 2 +- src/components/root.tsx | 12 +++++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/big_picture.tsx b/src/components/big_picture.tsx index 988dcdf..e47cae5 100644 --- a/src/components/big_picture.tsx +++ b/src/components/big_picture.tsx @@ -7,7 +7,6 @@ export interface Props { image: Model.Image; onClose: () => void; width: number; - height: number; } export class BigPicture extends React.PureComponent { @@ -23,7 +22,7 @@ export class BigPicture extends React.PureComponent { render() { const scaleWidth = this.props.image.width / this.props.width; - const scaleHeight = this.props.image.height / (this.props.height - 80); + const scaleHeight = this.props.image.height / (window.innerHeight - 80); const scale = Math.max(scaleWidth, scaleHeight); return ( diff --git a/src/components/grid.tsx b/src/components/grid.tsx index 179be49..5366163 100644 --- a/src/components/grid.tsx +++ b/src/components/grid.tsx @@ -86,5 +86,5 @@ export class Grid extends React.PureComponent { } private _rowHeight = (): number => - this.props.width > 500 ? ROW_HEIGHT : MOBILE_ROW_HEIGHT; + this.props.width > 900 ? ROW_HEIGHT : MOBILE_ROW_HEIGHT; } diff --git a/src/components/root.tsx b/src/components/root.tsx index 98300e9..88811f5 100644 --- a/src/components/root.tsx +++ b/src/components/root.tsx @@ -24,13 +24,12 @@ export class Root extends React.PureComponent { return Math.min( window.innerWidth, window.outerWidth || Infinity, - document.getElementById("mount")!.clientWidth || Infinity + document.body.clientWidth ); }; private _viewHeight = (): number => { return Math.min( - window.innerHeight, window.outerHeight || Infinity, document.body.clientHeight || Infinity ); @@ -55,6 +54,14 @@ export class Root extends React.PureComponent { window.onresize = this._onViewChange; window.onscroll = this._onViewChange; + try { + screen.orientation.onchange = this._onViewChange; + } catch (e) {} + + try { + window.onorientationchange = this._onViewChange; + } catch (e) {} + window.onpopstate = this._loadHash; } @@ -90,7 +97,6 @@ export class Root extends React.PureComponent { image={this.state.selectedImage} onClose={this._showGrid} width={this.state.width} - height={this.state.height} /> ) : null;