Fix preserving scroll position for rtl reading direction and ltr theme direction

This commit is contained in:
schroda
2026-06-05 18:55:15 +02:00
parent ac1845306d
commit 4f10cb06e3
3 changed files with 19 additions and 4 deletions

View File

@@ -54,6 +54,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- (**Reader**) Fix jumping back to the first page on window resize - (**Reader**) Fix jumping back to the first page on window resize
- (**Reader**) Fix chapter not getting marked as read in continuous reading mode in case the last page is not big enough to get marked as the current page - (**Reader**) Fix chapter not getting marked as read in continuous reading mode in case the last page is not big enough to get marked as the current page
- (**Reader**) Fix infinite scrolling sometimes not opening previous/next chapter - (**Reader**) Fix infinite scrolling sometimes not opening previous/next chapter
- (**Reader**) Fix preserving scroll position with RTL reading direction and a language that is read RTL
- (**Browse**) Fix showing only nsfw sources in the browse source page when the "show nsfw" setting is disabled - (**Browse**) Fix showing only nsfw sources in the browse source page when the "show nsfw" setting is disabled
## [20260509.01] (r3147) - 2026-05-09 ## [20260509.01] (r3147) - 2026-05-09

View File

@@ -230,6 +230,7 @@ const BaseReaderViewer = ({
pageScaleMode, pageScaleMode,
shouldStretchPage, shouldStretchPage,
readerWidth, readerWidth,
themeDirection,
); );
useLayoutEffect(() => { useLayoutEffect(() => {

View File

@@ -12,9 +12,9 @@ import type {
IReaderSettingsManga, IReaderSettingsManga,
ReaderPageScaleMode, ReaderPageScaleMode,
ReaderStateChapters, ReaderStateChapters,
ReadingDirection,
ReadingMode, ReadingMode,
} from '@/features/reader/Reader.types.ts'; } from '@/features/reader/Reader.types.ts';
import { ReadingDirection } from '@/features/reader/Reader.types.ts';
import { import {
isContinuousReadingMode, isContinuousReadingMode,
isContinuousVerticalReadingMode, isContinuousVerticalReadingMode,
@@ -24,6 +24,7 @@ import {
import { getPreviousNextChapterVisibility } from '@/features/reader/Reader.utils.ts'; import { getPreviousNextChapterVisibility } from '@/features/reader/Reader.utils.ts';
import type { ChapterIdInfo, TChapterReader } from '@/features/chapter/Chapter.types.ts'; import type { ChapterIdInfo, TChapterReader } from '@/features/chapter/Chapter.types.ts';
import { getReaderPagesStore, getReaderSettingsStore } from '@/features/reader/stores/ReaderStore.ts'; import { getReaderPagesStore, getReaderSettingsStore } from '@/features/reader/stores/ReaderStore.ts';
import type { Direction } from '@mui/material/styles';
const shouldPreserveOnResizeChange = ( const shouldPreserveOnResizeChange = (
readingMode: ReadingMode, readingMode: ReadingMode,
@@ -177,7 +178,12 @@ const useScrollPreservationData = (
return dataRef; return dataRef;
}; };
const usePreserveOnLeadingPageRender = (scrollElementRef: RefObject<HTMLElement | null>, readingMode: ReadingMode) => { const usePreserveOnLeadingPageRender = (
scrollElementRef: RefObject<HTMLElement | null>,
readingMode: ReadingMode,
readingDirection: ReadingDirection,
themeDirection: Direction,
) => {
const preservationDataRef = useScrollPreservationData(scrollElementRef); const preservationDataRef = useScrollPreservationData(scrollElementRef);
const isContinuousReadingModeActive = isContinuousReadingMode(readingMode); const isContinuousReadingModeActive = isContinuousReadingMode(readingMode);
@@ -212,7 +218,13 @@ const usePreserveOnLeadingPageRender = (scrollElementRef: RefObject<HTMLElement
return entry.target.offsetTop < top; return entry.target.offsetTop < top;
} }
return entry.target.offsetLeft < left; if (themeDirection === 'rtl') {
return entry.target.offsetLeft < left;
}
return readingDirection === ReadingDirection.LTR
? entry.target.offsetLeft < left
: entry.target.offsetLeft > left;
}); });
const includesElementsBeforeScrollPosition = !!entriesBeforeScrollPosition.length; const includesElementsBeforeScrollPosition = !!entriesBeforeScrollPosition.length;
@@ -364,6 +376,7 @@ export const useReaderPreserveScrollPosition = (
pageScaleMode: ReaderPageScaleMode, pageScaleMode: ReaderPageScaleMode,
shouldStretchPage: boolean, shouldStretchPage: boolean,
readerWidth: IReaderSettingsManga['readerWidth'], readerWidth: IReaderSettingsManga['readerWidth'],
themeDirection: Direction,
) => { ) => {
usePreserveOnInfiniteScrollPreviousChapterInitialRender( usePreserveOnInfiniteScrollPreviousChapterInitialRender(
scrollElementRef, scrollElementRef,
@@ -374,7 +387,7 @@ export const useReaderPreserveScrollPosition = (
visibleChapters, visibleChapters,
isContinuousReadingMode(readingMode), isContinuousReadingMode(readingMode),
); );
usePreserveOnLeadingPageRender(scrollElementRef, readingMode); usePreserveOnLeadingPageRender(scrollElementRef, readingMode, readingDirection, themeDirection);
usePreserveOnWindowResize(readingMode, pageScaleMode, currentPageIndex); usePreserveOnWindowResize(readingMode, pageScaleMode, currentPageIndex);
usePreserveOnValueChange(readingDirection, currentPageIndex); usePreserveOnValueChange(readingDirection, currentPageIndex);
usePreserveOnValueChange(readingMode, currentPageIndex); usePreserveOnValueChange(readingMode, currentPageIndex);