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

@@ -30,7 +30,7 @@ const isSinglePage = (index: number, spreadPages: boolean[]): boolean => {
};
export default function DoublePagedPager(props: IReaderProps) {
const { pages, settings, setCurPage, curPage, nextChapter, prevChapter } = props;
const { pages, settings, setCurPage, initialPage, curPage, nextChapter, prevChapter } = props;
const selfRef = useRef<HTMLDivElement>(null);
const pagesRef = useRef<HTMLImageElement[]>([]);
@@ -186,6 +186,10 @@ export default function DoublePagedPager(props: IReaderProps) {
};
}, [selfRef, curPage, settings.readerType]);
useEffect(() => {
setCurPage(initialPage);
}, [initialPage]);
return (
<Box ref={selfRef}>
<Box id="preload" sx={{ display: 'none' }}>