Add option to disable "infinite chapter scroll"

This commit is contained in:
schroda
2025-04-26 23:19:01 +02:00
parent f9930b94ca
commit beda5096d1
10 changed files with 67 additions and 20 deletions

View File

@@ -175,8 +175,12 @@ export class ReaderControls {
scrollIntoView?: boolean,
) => void {
const { t } = useTranslation();
const { readingMode, shouldInformAboutMissingChapter, shouldInformAboutScanlatorChange } =
ReaderService.useSettings();
const {
readingMode,
shouldInformAboutMissingChapter,
shouldInformAboutScanlatorChange,
shouldUseInfiniteScroll,
} = ReaderService.useSettings();
const {
currentChapter,
previousChapter,
@@ -239,7 +243,7 @@ export class ReaderControls {
const isAlreadyLoaded =
lastLeadingChapterSourceOrder <= chapterToOpen.sourceOrder &&
lastTrailingChapterSourceOrder >= chapterToOpen.sourceOrder;
const keepRenderedChapters = !scrollIntoView || isAlreadyLoaded;
const keepRenderedChapters = shouldUseInfiniteScroll && (!scrollIntoView || isAlreadyLoaded);
if (keepRenderedChapters) {
setReaderStateChapters((prevState) =>
@@ -255,7 +259,10 @@ export class ReaderControls {
}
openChapter(chapterToOpen, {
resumeMode: getReaderOpenChapterResumeMode(isSpecificChapterMode, isPreviousChapter),
resumeMode: getReaderOpenChapterResumeMode(
isSpecificChapterMode || !keepRenderedChapters,
isPreviousChapter,
),
updateInitialChapter: !keepRenderedChapters,
});
} catch (error) {
@@ -274,6 +281,7 @@ export class ReaderControls {
shouldInformAboutScanlatorChange,
lastLeadingChapterSourceOrder,
lastTrailingChapterSourceOrder,
shouldUseInfiniteScroll,
],
);
}