migrate DoublePagedPager to Mui 5 (#91)
This commit is contained in:
@@ -5,34 +5,17 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import makeStyles from '@mui/styles/makeStyles';
|
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
import { Box } from '@mui/system';
|
||||||
import Page from '../Page';
|
import Page from '../Page';
|
||||||
import DoublePage from '../DoublePage';
|
import DoublePage from '../DoublePage';
|
||||||
|
|
||||||
const useStyles = (settings: IReaderSettings) => makeStyles({
|
|
||||||
preload: {
|
|
||||||
display: 'none',
|
|
||||||
},
|
|
||||||
reader: {
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: (settings.readerType === 'DoubleLTR') ? 'row' : 'row-reverse',
|
|
||||||
justifyContent: 'center',
|
|
||||||
margin: '0 auto',
|
|
||||||
width: 'auto',
|
|
||||||
height: 'auto',
|
|
||||||
overflowX: 'scroll',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function DoublePagedPager(props: IReaderProps) {
|
export default function DoublePagedPager(props: IReaderProps) {
|
||||||
const {
|
const {
|
||||||
pages, settings, setCurPage, curPage, nextChapter, prevChapter,
|
pages, settings, setCurPage, curPage, nextChapter, prevChapter,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const classes = useStyles(settings)();
|
|
||||||
|
|
||||||
const selfRef = useRef<HTMLDivElement>(null);
|
const selfRef = useRef<HTMLDivElement>(null);
|
||||||
const pagesRef = useRef<HTMLImageElement[]>([]);
|
const pagesRef = useRef<HTMLImageElement[]>([]);
|
||||||
|
|
||||||
@@ -192,8 +175,8 @@ export default function DoublePagedPager(props: IReaderProps) {
|
|||||||
}, [selfRef, curPage, settings.readerType]);
|
}, [selfRef, curPage, settings.readerType]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={selfRef}>
|
<Box ref={selfRef}>
|
||||||
<div id="preload" className={classes.preload}>
|
<Box id="preload" sx={{ display: 'none' }}>
|
||||||
{
|
{
|
||||||
pages.map((page) => (
|
pages.map((page) => (
|
||||||
<img
|
<img
|
||||||
@@ -205,8 +188,19 @@ export default function DoublePagedPager(props: IReaderProps) {
|
|||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</div>
|
</Box>
|
||||||
<div id="display" className={classes.reader} />
|
<Box
|
||||||
</div>
|
id="display"
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: (settings.readerType === 'DoubleLTR') ? 'row' : 'row-reverse',
|
||||||
|
justifyContent: 'center',
|
||||||
|
margin: '0 auto',
|
||||||
|
width: 'auto',
|
||||||
|
height: 'auto',
|
||||||
|
overflowX: 'scroll',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user