Prevent layout shifts in continuous pagers

I was unable to find a fix for this problem, thus, the only solution I see is disabling this functionality for the continuous readers.

Due to preloading leading pages, the layout got shifted once the pages got loaded.
This messed with the scroll position which caused the top of the scrolled into views pages to not be at the top of the viewport anymore.
This commit is contained in:
schroda
2024-12-31 02:42:17 +01:00
parent 1d955257dd
commit f808614e6c
2 changed files with 13 additions and 3 deletions

View File

@@ -43,8 +43,15 @@ const BaseBasePager = ({
}) => {
const previousCurrentPageIndex = useRef(-1);
const pagesIndexesToRender = useMemo(
() => getPageIndexesToLoad(currentPageIndex, pages, previousCurrentPageIndex.current, imagePreLoadAmount),
[currentPageIndex, pages, imagePreLoadAmount],
() =>
getPageIndexesToLoad(
currentPageIndex,
pages,
previousCurrentPageIndex.current,
imagePreLoadAmount,
readingMode,
),
[currentPageIndex, pages, imagePreLoadAmount, readingMode],
);
useEffect(() => {
previousCurrentPageIndex.current = currentPageIndex;