From ebac415b09baf252e89fb61293bcae04d3a07032 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Mon, 13 Apr 2026 14:22:05 +0200 Subject: [PATCH] Fix tapzone opening previous/next chapter in continuous horizontal mode with inverted reading direction The logic to detect if the horizontal scroll position was at the start or end of the element was not correct in case the readers reading direction was inverted compared to the browser themes reading direction. example: - theme ltr + reader ltr => worked - theme ltr + reader rtl => broken - theme rtl + reader ltr => broken - theme rtl + reader rtl => worked --- CHANGELOG.md | 1 + .../reader/services/ReaderControls.ts | 25 ++++++------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ca38c3f..ce1b82bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - (**Reader**) Fix page shift when toggling the "offset double spreads" setting (currently: enable: shift to the right; disable: shift to the left – now: inverted) - (**Reader**) Fix "auto webtoon mode" detection for manga source languages other than english and the current selected language - (**Reader**) Fix the reader transition page previous chapter scanlator name showing the chapter name instead of the scanlator name +- (**Reader**) Fix opening the previous/next chapter in the continuous horizontal mode with inverted reading direction - (**Manga**) Fix dynamic manga page color theme not getting reset after leaving the manga page ## [20251230.01] (r2937) - 2025-12-30 diff --git a/src/features/reader/services/ReaderControls.ts b/src/features/reader/services/ReaderControls.ts index 8a1713ee..506642b1 100644 --- a/src/features/reader/services/ReaderControls.ts +++ b/src/features/reader/services/ReaderControls.ts @@ -19,7 +19,7 @@ import { getPageForMousePos, getProgressBarPositionInfo, } from '@/features/reader/overlay/progress-bar/ReaderProgressBar.utils.tsx'; -import { getCurrentTheme, getOptionForDirection } from '@/features/theme/services/ThemeCreator.ts'; +import { getOptionForDirection } from '@/features/theme/services/ThemeCreator.ts'; import { ReaderService } from '@/features/reader/services/ReaderService.ts'; import type { PageInViewportType, @@ -66,19 +66,11 @@ const getScrollDirectionInvert = ( ): 1 | -1 => { if (scrollDirection === ScrollDirection.X) { if (scrollOffset === ScrollOffset.BACKWARD) { - if (themeDirection === 'ltr') { - return -1; - } - - return 1; + return getOptionForDirection(-1, 1, themeDirection); } if (scrollOffset === ScrollOffset.FORWARD) { - if (themeDirection === 'ltr') { - return 1; - } - - return -1; + return getOptionForDirection(1, -1, themeDirection); } } @@ -106,19 +98,16 @@ export class ReaderControls { } const themeDirectionOfReadingDirection = READING_DIRECTION_TO_THEME_DIRECTION[readingDirection]; - const areReadingDirectionsEqual = getCurrentTheme().direction === themeDirectionOfReadingDirection; const isContinuousReadingModeActive = isContinuousReadingMode(readingMode); const isAtStartY = Math.abs(element.scrollTop) <= 1; const isAtEndY = Math.floor(element.scrollTop) === element.scrollHeight - element.clientHeight || Math.ceil(element.scrollTop) === element.scrollHeight - element.clientHeight; - const isAtStartX = Math.abs(element.scrollLeft) <= 1; + const isAtStartX = Math.floor(Math.abs(element.scrollLeft)) === 0; const isAtEndX = - element.scrollWidth - element.clientWidth - Math.floor(Math.abs(element.scrollLeft)) <= 1 || - element.scrollWidth - element.clientWidth - Math.ceil(Math.abs(element.scrollLeft)) <= 1; - const isAtStartXForDirection = areReadingDirectionsEqual ? isAtStartX : isAtEndX; - const isAtEndXForDirection = areReadingDirectionsEqual ? isAtEndX : isAtStartX; + Math.floor(Math.abs(element.scrollLeft)) === element.scrollWidth - element.clientWidth || + Math.ceil(Math.abs(element.scrollLeft)) === element.scrollWidth - element.clientWidth; const scrollAmount = scrollAmountPercentage / 100; const scrollDirection = getScrollDirectionInvert(direction, offset, themeDirectionOfReadingDirection); @@ -152,7 +141,7 @@ export class ReaderControls { switch (direction) { case ScrollDirection.X: - doScroll(isAtStartXForDirection, isAtEndXForDirection, { + doScroll(isAtStartX, isAtEndX, { left: getNewScrollPosition(element.scrollLeft, element.clientWidth), }); break;