Better portrait support (#41)
* Better portrait support * re-added min and max width. Fixed react hook syntax
This commit is contained in:
@@ -11,6 +11,22 @@ import SpinnerImage from 'components/SpinnerImage';
|
|||||||
import useLocalStorage from 'util/useLocalStorage';
|
import useLocalStorage from 'util/useLocalStorage';
|
||||||
|
|
||||||
function imageStyle(settings: IReaderSettings): any {
|
function imageStyle(settings: IReaderSettings): any {
|
||||||
|
const [dimensions, setDimensions] = React.useState({
|
||||||
|
height: window.innerHeight,
|
||||||
|
width: window.innerWidth,
|
||||||
|
});
|
||||||
|
React.useEffect(() => {
|
||||||
|
function handleResize() {
|
||||||
|
setDimensions({
|
||||||
|
height: window.innerHeight,
|
||||||
|
width: window.innerWidth,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', handleResize);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
if (settings.readerType === 'DoubleLTR'
|
if (settings.readerType === 'DoubleLTR'
|
||||||
|| settings.readerType === 'DoubleRTL'
|
|| settings.readerType === 'DoubleRTL'
|
||||||
|| settings.readerType === 'ContinuesHorizontalLTR'
|
|| settings.readerType === 'ContinuesHorizontalLTR'
|
||||||
@@ -32,7 +48,7 @@ function imageStyle(settings: IReaderSettings): any {
|
|||||||
display: 'block',
|
display: 'block',
|
||||||
marginBottom: settings.readerType === 'ContinuesVertical' ? '15px' : 0,
|
marginBottom: settings.readerType === 'ContinuesVertical' ? '15px' : 0,
|
||||||
minWidth: '50vw',
|
minWidth: '50vw',
|
||||||
width: '100%',
|
width: dimensions.width < dimensions.height ? '100vw' : '100%',
|
||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -105,7 +121,7 @@ const Page = React.forwardRef((props: IProps, ref: any) => {
|
|||||||
}, [handleVerticalScroll]);
|
}, [handleVerticalScroll]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={ref} style={{ margin: '0 auto' }}>
|
<div ref={ref} style={{ margin: 'auto' }}>
|
||||||
<SpinnerImage
|
<SpinnerImage
|
||||||
src={`${src}?useCache=${useCache}`}
|
src={`${src}?useCache=${useCache}`}
|
||||||
onImageLoad={onImageLoad}
|
onImageLoad={onImageLoad}
|
||||||
|
|||||||
Reference in New Issue
Block a user