From 9b58a94f981670aa8b4aafcacf847e651f3746c0 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 5 Feb 2025 01:27:42 +0100 Subject: [PATCH] Fix image preload amount for current chapter For the current chapter the "pages to render" always include the current page --- src/modules/reader/utils/ReaderPager.utils.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/reader/utils/ReaderPager.utils.tsx b/src/modules/reader/utils/ReaderPager.utils.tsx index ec6f2263..51e6c0e7 100644 --- a/src/modules/reader/utils/ReaderPager.utils.tsx +++ b/src/modules/reader/utils/ReaderPager.utils.tsx @@ -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)