and some more

This commit is contained in:
Aaron Gutierrez
2022-01-19 21:16:09 -07:00
parent 9538523723
commit 301d712763
3 changed files with 11 additions and 6 deletions

View File

@@ -7,7 +7,6 @@ export interface Props {
image: Model.Image; image: Model.Image;
onClose: () => void; onClose: () => void;
width: number; width: number;
height: number;
} }
export class BigPicture extends React.PureComponent<Props, {}> { export class BigPicture extends React.PureComponent<Props, {}> {
@@ -23,7 +22,7 @@ export class BigPicture extends React.PureComponent<Props, {}> {
render() { render() {
const scaleWidth = this.props.image.width / this.props.width; 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); const scale = Math.max(scaleWidth, scaleHeight);
return ( return (

View File

@@ -86,5 +86,5 @@ export class Grid extends React.PureComponent<Props, {}> {
} }
private _rowHeight = (): number => private _rowHeight = (): number =>
this.props.width > 500 ? ROW_HEIGHT : MOBILE_ROW_HEIGHT; this.props.width > 900 ? ROW_HEIGHT : MOBILE_ROW_HEIGHT;
} }

View File

@@ -24,13 +24,12 @@ export class Root extends React.PureComponent<Props, State> {
return Math.min( return Math.min(
window.innerWidth, window.innerWidth,
window.outerWidth || Infinity, window.outerWidth || Infinity,
document.getElementById("mount")!.clientWidth || Infinity document.body.clientWidth
); );
}; };
private _viewHeight = (): number => { private _viewHeight = (): number => {
return Math.min( return Math.min(
window.innerHeight,
window.outerHeight || Infinity, window.outerHeight || Infinity,
document.body.clientHeight || Infinity document.body.clientHeight || Infinity
); );
@@ -55,6 +54,14 @@ export class Root extends React.PureComponent<Props, State> {
window.onresize = this._onViewChange; window.onresize = this._onViewChange;
window.onscroll = 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; window.onpopstate = this._loadHash;
} }
@@ -90,7 +97,6 @@ export class Root extends React.PureComponent<Props, State> {
image={this.state.selectedImage} image={this.state.selectedImage}
onClose={this._showGrid} onClose={this._showGrid}
width={this.state.width} width={this.state.width}
height={this.state.height}
/> />
) : null; ) : null;