migrate VerticalPager to Mui 5 (#94)

This commit is contained in:
Aria Moradi
2021-12-03 10:35:55 +03:30
committed by GitHub
parent a8444e5101
commit 1a62bad4a6

View File

@@ -5,27 +5,15 @@
* 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/. */
import makeStyles from '@mui/styles/makeStyles';
import React, { useEffect, useRef } from 'react';
import { Box } from '@mui/system';
import Page from '../Page';
const useStyles = makeStyles({
reader: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
margin: '0 auto',
width: '100%',
},
});
export default function VerticalReader(props: IReaderProps) {
const {
pages, settings, setCurPage, curPage, nextChapter, prevChapter,
} = props;
const classes = useStyles();
const selfRef = useRef<HTMLDivElement>(null);
const pagesRef = useRef<HTMLDivElement[]>([]);
@@ -105,7 +93,16 @@ export default function VerticalReader(props: IReaderProps) {
}, [pagesRef.current.length]);
return (
<div ref={selfRef} className={classes.reader}>
<Box
ref={selfRef}
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
margin: '0 auto',
width: '100%',
}}
>
{
pages.map((page) => (
<Page
@@ -119,6 +116,6 @@ export default function VerticalReader(props: IReaderProps) {
/>
))
}
</div>
</Box>
);
}