Prevent blinking on page switch in single mode
This commit is contained in:
@@ -18,6 +18,7 @@ export const isHorizontalReaderType = (readerType: ReaderType): boolean =>
|
|||||||
['ContinuesHorizontalLTR', 'ContinuesHorizontalRTL'].includes(readerType);
|
['ContinuesHorizontalLTR', 'ContinuesHorizontalRTL'].includes(readerType);
|
||||||
|
|
||||||
export function imageStyle(settings: IReaderSettings): CSSProperties {
|
export function imageStyle(settings: IReaderSettings): CSSProperties {
|
||||||
|
const isDoublePageReader = ['DoubleRTL', 'DoubleLTR'].includes(settings.readerType);
|
||||||
const isVertical = settings.readerType === 'ContinuesVertical';
|
const isVertical = settings.readerType === 'ContinuesVertical';
|
||||||
const isHorizontal = isHorizontalReaderType(settings.readerType);
|
const isHorizontal = isHorizontalReaderType(settings.readerType);
|
||||||
|
|
||||||
@@ -63,10 +64,11 @@ interface IProps {
|
|||||||
index: number;
|
index: number;
|
||||||
onImageLoad: () => void;
|
onImageLoad: () => void;
|
||||||
settings: IReaderSettings;
|
settings: IReaderSettings;
|
||||||
|
display?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Page = forwardRef((props: IProps, ref: any) => {
|
export const Page = forwardRef((props: IProps, ref: any) => {
|
||||||
const { src, index, onImageLoad, settings } = props;
|
const { src, index, onImageLoad, settings, display = true } = props;
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobileWidth = useMediaQuery(theme.breakpoints.down('md'));
|
const isMobileWidth = useMediaQuery(theme.breakpoints.down('md'));
|
||||||
@@ -78,7 +80,7 @@ export const Page = forwardRef((props: IProps, ref: any) => {
|
|||||||
<Box
|
<Box
|
||||||
ref={ref}
|
ref={ref}
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex',
|
display: display ? 'flex' : 'none',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
|
|||||||
@@ -121,7 +121,16 @@ export function PagedPager(props: IReaderProps) {
|
|||||||
}}
|
}}
|
||||||
onClick={clickControl}
|
onClick={clickControl}
|
||||||
>
|
>
|
||||||
<Page key={curPage} index={curPage} onImageLoad={() => {}} src={pages[curPage].src} settings={settings} />
|
{pages.map(({ index, src }) => (
|
||||||
|
<Page
|
||||||
|
key={src}
|
||||||
|
index={index}
|
||||||
|
onImageLoad={() => {}}
|
||||||
|
src={src}
|
||||||
|
settings={settings}
|
||||||
|
display={index === curPage}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user