Skip to content

Commit

Permalink
Fix page turn triggered when not selecting
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfactotum committed Oct 9, 2023
1 parent 36b8817 commit 1013855
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/reader/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ class Reader {
emit({ type: 'show-image', base64, mimetype }))
.catch(e => console.error(e)))

doc.addEventListener('click', () => {
let isSelecting = false
doc.addEventListener('pointerdown', () => isSelecting = true)
doc.addEventListener('pointerup', () => {
isSelecting = false
const range = getSelectionRange(doc)
if (!range) return
const pos = getPosition(range)
Expand All @@ -440,6 +443,7 @@ class Reader {
// go to the next page when selecting to the end of a page
// this makes it possible to select across pages
doc.addEventListener('selectionchange', debounce(() => {
if (!isSelecting) return
if (this.view.renderer.getAttribute('flow') !== 'paginated') return
const { lastLocation } = this.view
if (!lastLocation) return
Expand Down

0 comments on commit 1013855

Please sign in to comment.