Allow auto scrolling with static reader overlay
This commit is contained in:
@@ -103,6 +103,7 @@ const BaseReaderViewer = forwardRef(
|
|||||||
pageGap,
|
pageGap,
|
||||||
customFilter,
|
customFilter,
|
||||||
shouldStretchPage,
|
shouldStretchPage,
|
||||||
|
isStaticNav,
|
||||||
readerNavBarWidth,
|
readerNavBarWidth,
|
||||||
setScrollbarXSize,
|
setScrollbarXSize,
|
||||||
setScrollbarYSize,
|
setScrollbarYSize,
|
||||||
@@ -144,6 +145,7 @@ const BaseReaderViewer = forwardRef(
|
|||||||
| 'pageGap'
|
| 'pageGap'
|
||||||
| 'customFilter'
|
| 'customFilter'
|
||||||
| 'shouldStretchPage'
|
| 'shouldStretchPage'
|
||||||
|
| 'isStaticNav'
|
||||||
> &
|
> &
|
||||||
Pick<TReaderScrollbarContext, 'setScrollbarXSize' | 'setScrollbarYSize'> &
|
Pick<TReaderScrollbarContext, 'setScrollbarXSize' | 'setScrollbarYSize'> &
|
||||||
Pick<NavbarContextType, 'readerNavBarWidth'> &
|
Pick<NavbarContextType, 'readerNavBarWidth'> &
|
||||||
@@ -282,7 +284,7 @@ const BaseReaderViewer = forwardRef(
|
|||||||
setShowPreview,
|
setShowPreview,
|
||||||
scrollElementRef,
|
scrollElementRef,
|
||||||
);
|
);
|
||||||
useReaderAutoScroll(isOverlayVisible, automaticScrolling);
|
useReaderAutoScroll(isOverlayVisible, automaticScrolling, isStaticNav);
|
||||||
useReaderPreserveScrollPosition(
|
useReaderPreserveScrollPosition(
|
||||||
scrollElementRef,
|
scrollElementRef,
|
||||||
currentChapter?.id,
|
currentChapter?.id,
|
||||||
@@ -479,6 +481,7 @@ export const ReaderViewer = withPropsFrom(
|
|||||||
'pageGap',
|
'pageGap',
|
||||||
'customFilter',
|
'customFilter',
|
||||||
'shouldStretchPage',
|
'shouldStretchPage',
|
||||||
|
'isStaticNav',
|
||||||
'readerNavBarWidth',
|
'readerNavBarWidth',
|
||||||
'transitionPageMode',
|
'transitionPageMode',
|
||||||
'setScrollbarXSize',
|
'setScrollbarXSize',
|
||||||
|
|||||||
@@ -8,17 +8,19 @@
|
|||||||
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useAutomaticScrolling } from '@/modules/core/hooks/useAutomaticScrolling.ts';
|
import { useAutomaticScrolling } from '@/modules/core/hooks/useAutomaticScrolling.ts';
|
||||||
|
import { IReaderSettings } from '@/modules/reader/types/Reader.types.ts';
|
||||||
|
|
||||||
export const useReaderAutoScroll = (
|
export const useReaderAutoScroll = (
|
||||||
isOverlayVisible: boolean,
|
isOverlayVisible: boolean,
|
||||||
automaticScrolling: ReturnType<typeof useAutomaticScrolling>,
|
automaticScrolling: ReturnType<typeof useAutomaticScrolling>,
|
||||||
|
isStaticNav: IReaderSettings['isStaticNav'],
|
||||||
): void => {
|
): void => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOverlayVisible) {
|
if (isOverlayVisible && !isStaticNav) {
|
||||||
automaticScrolling.pause();
|
automaticScrolling.pause();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
automaticScrolling.resume();
|
automaticScrolling.resume();
|
||||||
}, [isOverlayVisible, automaticScrolling.isPaused]);
|
}, [isOverlayVisible, automaticScrolling.isPaused, isStaticNav]);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user