Reduce image rerenders in continuous reading modes on page change

In continuous reading modes the pages are always rendered regardless of if they are visible or not. This is the case to prevent layout shifts when prepending pages while scrolling up.

However, this means that a pages "load priority" and its "should load" flag changes everytime the current page changes, which causes unnecessary rerenders.
The "load priority" and "should load" flag do not matter once a page has been loaded and therefore should stay consistent once loaded.
This commit is contained in:
schroda
2025-11-28 22:56:44 +01:00
parent 3a27461598
commit 3dcdca7166
3 changed files with 5 additions and 4 deletions

View File

@@ -258,10 +258,11 @@ const getPageDownloadPriority = (
currentPageIndex: number,
pageIndex: number,
totalPages: number,
isLoaded: boolean,
shouldLoad: boolean,
isPreloadMode: boolean,
): number => {
if (!shouldLoad || isPreloadMode) {
if (isLoaded || !shouldLoad || isPreloadMode) {
return Number.MAX_SAFE_INTEGER;
}
@@ -309,7 +310,7 @@ export const createReaderPage = (
src={url}
alt={alt}
display={display}
priority={getPageDownloadPriority(currentPageIndex, index, totalPages, shouldLoad, isPreloadMode)}
priority={getPageDownloadPriority(currentPageIndex, index, totalPages, isLoaded, shouldLoad, isPreloadMode)}
position={position}
onLoad={onLoad}
onError={onError}

View File

@@ -39,7 +39,7 @@ const BaseReaderHorizontalPager = ({
isPreloadMode,
onLoad,
onError,
shouldLoad,
shouldLoad || pageLoadStates[page.primary.index].loaded,
!isPreloadMode,
currentPageIndex,
totalPages,

View File

@@ -36,7 +36,7 @@ const BaseReaderVerticalPager = ({
isPreloadMode,
onLoad,
onError,
shouldLoad,
shouldLoad || pageLoadStates[page.primary.index].loaded,
!isPreloadMode,
currentPageIndex,
totalPages,