Fix scrolling to range following auto hyphen in different column

This commit is contained in:
John Factotum
2023-03-20 00:33:15 +08:00
parent c510d83ea2
commit 1511884137
+6 -2
View File
@@ -573,9 +573,13 @@ export class Paginator {
return this.#scrollTo(offset, reason) return this.#scrollTo(offset, reason)
} }
async #scrollToAnchor(select) { async #scrollToAnchor(select) {
const rect = uncollapse(this.#anchor).getBoundingClientRect?.() const rects = uncollapse(this.#anchor)?.getClientRects()
// if anchor is an element or a range // 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') await this.#scrollToRect(rect, 'anchor')
if (select) this.#selectAnchor() if (select) this.#selectAnchor()
return return