From fe76eccc0b2caf12838adb56d9abf6a34b87798c Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Mon, 4 Nov 2024 15:40:00 -0500 Subject: [PATCH] EPUB: Use RTL-aware canNavigate*() checks --- src/dom/epub/flow.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/dom/epub/flow.ts b/src/dom/epub/flow.ts index be01a863..1470d258 100644 --- a/src/dom/epub/flow.ts +++ b/src/dom/epub/flow.ts @@ -548,6 +548,24 @@ export class PaginatedFlow extends AbstractFlow { } } + canNavigateLeft() { + if (this._view.pageProgressionRTL) { + return this.canNavigateToNextPage(); + } + else { + return this.canNavigateToPreviousPage(); + } + } + + canNavigateRight() { + if (this._view.pageProgressionRTL) { + return this.canNavigateToPreviousPage(); + } + else { + return this.canNavigateToNextPage(); + } + } + navigateToFirstPage(): void { this.currentSectionIndex = this._view.renderers[0].section.index; this._sectionsContainer.scrollTo({ left: 0, top: 0 }); @@ -640,10 +658,10 @@ export class PaginatedFlow extends AbstractFlow { } let swipeAmount = (event.clientX - this._touchStartX) / PAGE_TURN_SWIPE_LENGTH_PX; // If on the first/last page, clamp the CSS variable so the indicator doesn't expand all the way - if (swipeAmount < 0 && !this.canNavigateToNextPage()) { + if (swipeAmount < 0 && !this.canNavigateRight()) { swipeAmount = Math.max(swipeAmount, -0.6); } - else if (swipeAmount > 0 && !this.canNavigateToPreviousPage()) { + else if (swipeAmount > 0 && !this.canNavigateLeft()) { swipeAmount = Math.min(swipeAmount, 0.6); } this._swipeIndicators.style.setProperty('--swipe-amount', swipeAmount.toString());