Skip to content

Commit 68481e6

Browse files
committed
EPUB/Snapshot: Better prevent page turns with selection
1 parent 23575f6 commit 68481e6

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/dom/epub/flow.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,10 @@ export class PaginatedFlow extends AbstractFlow {
820820
};
821821

822822
private _handlePointerMove = (event: PointerEvent) => {
823-
if (!this._touchDown || !event.isPrimary || event.buttons % 1 !== 0) {
823+
if (!this._touchDown
824+
|| !event.isPrimary
825+
|| event.buttons % 1 !== 0
826+
|| !this._iframeDocument.getSelection()!.isCollapsed) {
824827
return;
825828
}
826829
let swipeAmount = (event.clientX - this._touchStartX) / PAGE_TURN_SWIPE_LENGTH_PX;
@@ -835,10 +838,12 @@ export class PaginatedFlow extends AbstractFlow {
835838
};
836839

837840
private _handlePointerUp = (event: PointerEvent) => {
838-
if (!this._touchDown || !event.isPrimary) {
841+
if (!this._touchDown
842+
|| !event.isPrimary
843+
// No event.buttons check - "buttons" have now been released
844+
|| !this._iframeDocument.getSelection()!.isCollapsed) {
839845
return;
840846
}
841-
event.preventDefault();
842847
this._swipeIndicators.style.setProperty('--swipe-amount', '0');
843848
this._touchDown = false;
844849

@@ -870,7 +875,9 @@ export class PaginatedFlow extends AbstractFlow {
870875
};
871876

872877
private _handlePointerCancel = (event: PointerEvent) => {
873-
if (!this._touchDown || !event.isPrimary) {
878+
if (!this._touchDown
879+
|| !event.isPrimary) {
880+
// No event.buttons check - "buttons" have now been released
874881
return;
875882
}
876883
this._touchDown = false;

0 commit comments

Comments
 (0)