Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Better portrait support #41

Merged
merged 2 commits into from
Oct 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/components/manga/reader/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ import SpinnerImage from 'components/SpinnerImage';
import useLocalStorage from 'util/useLocalStorage';

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'
|| settings.readerType === 'DoubleRTL'
|| settings.readerType === 'ContinuesHorizontalLTR'
Expand All @@ -31,9 +47,8 @@ function imageStyle(settings: IReaderSettings): any {
return {
display: 'block',
marginBottom: settings.readerType === 'ContinuesVertical' ? '15px' : 0,
minWidth: '50vw',
width: '100%',
maxWidth: '100%',
width: dimensions.width < dimensions.height ? '100vw' : 'auto',
height: dimensions.width < dimensions.height ? 'auto' : '100vh',
};
}

Expand Down Expand Up @@ -105,7 +120,7 @@ const Page = React.forwardRef((props: IProps, ref: any) => {
}, [handleVerticalScroll]);

return (
<div ref={ref} style={{ margin: '0 auto' }}>
<div ref={ref} style={{ margin: 'auto' }}>
<SpinnerImage
src={`${src}?useCache=${useCache}`}
onImageLoad={onImageLoad}
Expand Down