Skip to content
Permalink
Browse files

Fix bug in scrolling things into view

FIX: Fix issue where scrolling with multiple scrollable containers sometimes moves to
the wrong position.

See https://discuss.prosemirror.net/t/problem-with-scrollintoview-handler/2570
  • Loading branch information
marijnh committed Mar 12, 2020
1 parent 6e03bf6 commit 3e9fba4d49b27b1d05b06219f850067e13ae60eb
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/domcoords.js
@@ -31,9 +31,11 @@ export function scrollRectIntoView(view, rect, startDOM) {
if (atTop) {
win.scrollBy(moveX, moveY)
} else {
let startX = parent.scrollLeft, startY = parent.scrollTop
if (moveY) parent.scrollTop += moveY
if (moveX) parent.scrollLeft += moveX
rect = {left: rect.left - moveX, top: rect.top - moveY, right: rect.right - moveX, bottom: rect.bottom - moveY}
let dX = parent.scrollX - startX, dY = parent.scrollY - startY
rect = {left: rect.left - dX, top: rect.top - dY, right: rect.right - dX, bottom: rect.bottom - dY}
}
}
if (atTop) break

0 comments on commit 3e9fba4

Please sign in to comment.
You can’t perform that action at this time.