Fix reader nav bar scroll to page (#236)

* Correctly scroll to page

Using "curPage" as the "initialPage" broke "scrolling up".
The page got reset to the first page in that case

* Support resume and scrolling to page for "DoublePagedPager"

* Support resume and scrolling to page for "PagedPager"

* Prevent "ReaderNavBar" from disappearing in "VerticalPager"

Due to handling the overflow on the "root" div and the "nav bar" being sticky and having a combined with of 100vw with the "vertical pager", once the first page was reached, that was behind the 100vw, the "nav bar" got moved out of the screen.
This made using the "nav bar" unusable for the "vertical pager".
This commit is contained in:
Daniel
2023-02-12 16:12:17 +01:00
committed by GitHub
parent b16b9eb55a
commit ad9a12b2ec
4 changed files with 30 additions and 9 deletions

View File

@@ -10,7 +10,7 @@ import { Box } from '@mui/system';
import Page from 'components/reader/Page';
export default function PagedReader(props: IReaderProps) {
const { pages, settings, setCurPage, curPage, nextChapter, prevChapter } = props;
const { pages, settings, setCurPage, initialPage, curPage, nextChapter, prevChapter } = props;
const selfRef = useRef<HTMLDivElement>(null);
@@ -86,6 +86,14 @@ export default function PagedReader(props: IReaderProps) {
};
}, [selfRef, curPage, settings.readerType]);
useEffect(() => {
// Delay scrolling to next cycle
setTimeout(() => {
// scroll last read page into view when initialPage changes
changePage(initialPage);
}, 0);
}, [initialPage]);
return (
<Box
ref={selfRef}