Skip to content

Commit

Permalink
Fix swiping pages in EPUB not working after using a gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
tnajdek committed Nov 13, 2024
1 parent 06c0b01 commit 644f868
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/dom/epub/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ export class PaginatedFlow extends AbstractFlow {
this._iframeDocument.addEventListener('pointerdown', this._handlePointerDown);
this._iframeDocument.addEventListener('pointermove', this._handlePointerMove);
this._iframeDocument.addEventListener('pointerup', this._handlePointerUp);
this._iframeDocument.addEventListener('pointerout', this._handlePointerCancel);
this._iframeDocument.addEventListener('pointercancel', this._handlePointerCancel);
this._iframeDocument.addEventListener('wheel', this._handleWheel, { passive: false });
this._iframeDocument.addEventListener('selectionchange', this._handleSelectionChange);
this._iframe.classList.add('flow-mode-paginated');
Expand All @@ -395,6 +397,8 @@ export class PaginatedFlow extends AbstractFlow {
this._iframeDocument.removeEventListener('pointerdown', this._handlePointerDown);
this._iframeDocument.removeEventListener('pointermove', this._handlePointerMove);
this._iframeDocument.removeEventListener('pointerup', this._handlePointerUp);
this._iframeDocument.removeEventListener('pointerout', this._handlePointerCancel);
this._iframeDocument.removeEventListener('pointercancel', this._handlePointerCancel);
this._iframeDocument.removeEventListener('wheel', this._handleWheel);
this._iframeDocument.removeEventListener('selectionchange', this._handleSelectionChange);
this._iframe.classList.remove('flow-mode-paginated');
Expand Down Expand Up @@ -697,6 +701,13 @@ export class PaginatedFlow extends AbstractFlow {
}
};

private _handlePointerCancel = (event: PointerEvent) => {
if (this._touchStartID === event.pointerId) {
this._touchStartID = null;
this._swipeIndicators.style.setProperty('--swipe-amount', '0');
}
};

private _handleWheel = debounce((event: WheelEvent) => {
let tableParent = (event.target as Element).closest('table, .table-like');
if (tableParent && tableParent.clientHeight < tableParent.scrollHeight) {
Expand Down

0 comments on commit 644f868

Please sign in to comment.