Preload previous/next chapter in reader

This commit is contained in:
schroda
2025-02-10 01:05:35 +01:00
parent 16c1edaa52
commit 174d850093
14 changed files with 185 additions and 44 deletions

View File

@@ -267,8 +267,9 @@ const getPageDownloadPriority = (
pageIndex: number,
totalPages: number,
shouldLoad: boolean,
isPreloadMode: boolean,
): number => {
if (!shouldLoad) {
if (!shouldLoad || isPreloadMode) {
return Number.MAX_SAFE_INTEGER;
}
@@ -288,6 +289,7 @@ export const createReaderPage = (
pagesIndex: number,
isPrimaryPage: boolean,
isLoaded: boolean,
isPreloadMode: boolean,
onLoad: ComponentProps<typeof ReaderPage>['onLoad'],
onError: ComponentProps<typeof ReaderPage>['onError'],
shouldLoad: boolean,
@@ -317,7 +319,7 @@ export const createReaderPage = (
src={url}
alt={alt}
display={display}
priority={getPageDownloadPriority(currentPageIndex, index, totalPages, shouldLoad)}
priority={getPageDownloadPriority(currentPageIndex, index, totalPages, shouldLoad, isPreloadMode)}
position={position}
onLoad={onLoad}
onError={onError}