mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Fix scrolling to range following auto hyphen in different column
This commit is contained in:
+6
-2
@@ -573,9 +573,13 @@ export class Paginator {
|
||||
return this.#scrollTo(offset, reason)
|
||||
}
|
||||
async #scrollToAnchor(select) {
|
||||
const rect = uncollapse(this.#anchor).getBoundingClientRect?.()
|
||||
const rects = uncollapse(this.#anchor)?.getClientRects()
|
||||
// if anchor is an element or a range
|
||||
if (rect) {
|
||||
if (rects) {
|
||||
// when the start of the range is immediately after a hyphen in the
|
||||
// previous column, there is an extra zero width rect in that column
|
||||
const rect = Array.from(rects)
|
||||
.find(r => r.width > 0 && r.height > 0) || rects[0]
|
||||
await this.#scrollToRect(rect, 'anchor')
|
||||
if (select) this.#selectAnchor()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user