Skip to content

Commit

Permalink
Refactor Selection#scrollIntoView()
Browse files Browse the repository at this point in the history
  • Loading branch information
luin authored and jhchen committed Jan 14, 2023
1 parent 6159f64 commit d2f689f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class Quill {
[index, length, , source] = overload(index, length, source);
this.selection.setRange(new Range(Math.max(0, index), length), source);
if (source !== Emitter.sources.SILENT) {
this.selection.scrollIntoView(this.scrollingContainer);
this.scrollIntoView();
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions core/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,6 @@ class Selection {
if (range == null) return;
const bounds = this.getBounds(range.index, range.length);
if (bounds == null) return;
const limit = this.scroll.length() - 1;
const [first] = this.scroll.line(Math.min(range.index, limit));
let last = first;
if (range.length > 0) {
[last] = this.scroll.line(Math.min(range.index + range.length, limit));
}
if (first == null || last == null) return;
const scrollBounds = scrollingContainer.getBoundingClientRect();
if (bounds.top < scrollBounds.top) {
scrollingContainer.scrollTop -= scrollBounds.top - bounds.top;
Expand Down

0 comments on commit d2f689f

Please sign in to comment.