mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-10-01 07:49:12 -04:00
Keep touchSelecting armed through collapsed selectionchange events
Chrome emits collapsed selectionchange events while the long-press word selection is being set up; clearing the flag on them disarmed the clamp before the selection ever became a Range.
This commit is contained in:
+3
-5
@@ -603,6 +603,7 @@ export class Paginator extends HTMLElement {
|
||||
doc.addEventListener('pointerdown', e => {
|
||||
touchSelecting = e.pointerType === 'touch'
|
||||
})
|
||||
doc.addEventListener('keydown', () => touchSelecting = false)
|
||||
let isKeyboardSelecting = false
|
||||
doc.addEventListener('keydown', () => isKeyboardSelecting = true)
|
||||
doc.addEventListener('keyup', () => isKeyboardSelecting = false)
|
||||
@@ -612,11 +613,8 @@ export class Paginator extends HTMLElement {
|
||||
if (!range) return
|
||||
const sel = doc.getSelection()
|
||||
if (!sel.rangeCount) return
|
||||
if (touchSelecting) {
|
||||
if (sel.isCollapsed) touchSelecting = false
|
||||
else if (sel.type === 'Range')
|
||||
this.#clampTouchSelection(sel, doc)
|
||||
}
|
||||
if (touchSelecting && sel.type === 'Range')
|
||||
this.#clampTouchSelection(sel, doc)
|
||||
if (isPointerSelecting && sel.type === 'Range')
|
||||
checkPointerSelection(range, sel)
|
||||
else if (isKeyboardSelecting) {
|
||||
|
||||
Reference in New Issue
Block a user