Skip to content

Commit

Permalink
Fix wheel scrolling and set forceScroll from op
Browse files Browse the repository at this point in the history
I broke this in 0ad53e0. Closes codemirror#4713.
  • Loading branch information
adrianheine committed Apr 28, 2017
1 parent b93ab2d commit c98bd22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/display/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function endOperation_finish(op) {
display.wheelStartX = display.wheelStartY = null

// Propagate the scroll position to the actual DOM scroller
if (op.scrollTop != null) setScrollTop(cm, op.scrollTop, true)
if (op.scrollTop != null) setScrollTop(cm, op.scrollTop, op.forceScroll)

if (op.scrollLeft != null) setScrollLeft(cm, op.scrollLeft, true, true)
// If we need to scroll a specific position into view, do so.
Expand Down
5 changes: 3 additions & 2 deletions src/display/scrolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,17 @@ export function scrollToCoordsRange(cm, from, to, margin) {
export function updateScrollTop(cm, val) {
if (Math.abs(cm.doc.scrollTop - val) < 2) return
if (!gecko) updateDisplaySimple(cm, {top: val})
setScrollTop(cm, val)
setScrollTop(cm, val, true)
if (gecko) updateDisplaySimple(cm)
startWorker(cm, 100)
}

export function setScrollTop(cm, val, forceScroll) {
val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val)
if (cm.display.scroller.scrollTop == val && !forceScroll) return
cm.doc.scrollTop = val
cm.display.scrollbars.setScrollTop(val)
cm.display.scroller.scrollTop = val
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val
}

// Sync scroller and scrollbar, ensure the gutter elements are
Expand Down

0 comments on commit c98bd22

Please sign in to comment.