mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-10-01 07:49:12 -04:00
Fix clamp coordinates: caretRangeFromPoint needs content-space bounds
This commit is contained in:
+4
-1
@@ -972,7 +972,10 @@ export class Paginator extends HTMLElement {
|
||||
: range.compareBoundaryPoints(Range.END_TO_END, probe) >= 0) return
|
||||
const rect = probe.getBoundingClientRect()
|
||||
if (!rect) return
|
||||
const x = backward ? this.start + 1 : this.end - 1
|
||||
const size = this.#rtl ? -this.size : this.size
|
||||
const x = backward
|
||||
? this.start - size + 1
|
||||
: this.end - size - 1
|
||||
const caret = doc.caretRangeFromPoint?.(x, rect.top)
|
||||
?? doc.caretPositionFromPoint?.(x, rect.top)
|
||||
if (!caret) return
|
||||
|
||||
Reference in New Issue
Block a user