Update "actualPages" immediately

Instead of immediately updating the value once the page count changed, it got updated after "pagesToSpreadState" changed, which was after the rendering finished.

This was the actual root cause of what was tried to be fixed with 9ab6ec89c7
This commit is contained in:
schroda
2024-12-31 13:19:58 +01:00
parent 36ae02d2bd
commit 3bab657c52

View File

@@ -139,7 +139,7 @@ const BaseReaderViewer = forwardRef(
const imageRefs = useRef<(HTMLElement | null)[]>(pages.map(() => null)); const imageRefs = useRef<(HTMLElement | null)[]>(pages.map(() => null));
const actualPages = useMemo(() => { const actualPages = useMemo(() => {
const arePagesLoaded = pageUrls.length; const arePagesLoaded = !!totalPages;
if (!arePagesLoaded) { if (!arePagesLoaded) {
return pages; return pages;
} }
@@ -154,7 +154,7 @@ const BaseReaderViewer = forwardRef(
} }
return pages; return pages;
}, [pagesToSpreadState, readingMode, shouldOffsetDoubleSpreads, readingDirection]); }, [pagesToSpreadState, readingMode, shouldOffsetDoubleSpreads, readingDirection, totalPages]);
const Pager = useMemo(() => getPagerForReadingMode(readingMode), [readingMode]); const Pager = useMemo(() => getPagerForReadingMode(readingMode), [readingMode]);
const inViewportType = READING_MODE_TO_IN_VIEWPORT_TYPE[readingMode]; const inViewportType = READING_MODE_TO_IN_VIEWPORT_TYPE[readingMode];