Fix image preload amount for current chapter

For the current chapter the "pages to render" always include the current page
This commit is contained in:
schroda
2025-02-05 01:27:42 +01:00
parent 19f2d99345
commit 9b58a94f98

View File

@@ -579,7 +579,8 @@ export const getPageIndexesToLoad = (
// do not load previous pages for continuous pagers to prevent layout shifts due to leading pages getting loaded
const startPagesIndex = !isContinuousReadingMode(readingMode) ? startPagesIndexTrailingIncluded : currentPageIndex;
const endPagesIndex = currentPagesIndex + finalImagePreLoadAmount * directionInvert;
const pagesToRenderLength = Math.max(1, Math.abs(endPagesIndex - startPagesIndex));
// add 1 for the current page in case it's the current chapter, otherwise, only the preload amount should get rendered
const pagesToRenderLength = Math.max(1, Math.abs(endPagesIndex - startPagesIndex) + Number(isCurrentChapter));
return Array(pagesToRenderLength)
.fill(1)