Ignore 'scroll' events when an update is pending

This prevents feedback loops where we handle stale 'scroll' events
for scrolls requested in the model layer. It prevents jitter when
autoscrolling with the cursor.
This commit is contained in:
Nathan Sobo
2014-07-02 10:11:35 -06:00
parent 7202f497db
commit 17fa580ecd
2 changed files with 3 additions and 3 deletions

View File

@@ -724,11 +724,11 @@ describe "EditorComponent", ->
# Add decorations that are out of range
marker2 = editor.displayBuffer.markBufferRange([[9, 0], [9, 0]])
editor.addDecorationForMarker(marker2, type: ['gutter', 'line'], class: 'b')
runSetImmediateCallbacks()
# Scroll decorations into view
verticalScrollbarNode.scrollTop = 2.5 * lineHeightInPixels
verticalScrollbarNode.dispatchEvent(new UIEvent('scroll'))
runSetImmediateCallbacks()
expect(lineAndLineNumberHaveClass(9, 'b')).toBe true
# Fold a line to move the decorations

View File

@@ -529,7 +529,7 @@ EditorComponent = React.createClass
onVerticalScroll: (scrollTop) ->
{editor} = @props
return if scrollTop is editor.getScrollTop()
return if @updateRequested or scrollTop is editor.getScrollTop()
animationFramePending = @pendingScrollTop?
@pendingScrollTop = scrollTop
@@ -542,7 +542,7 @@ EditorComponent = React.createClass
onHorizontalScroll: (scrollLeft) ->
{editor} = @props
return if scrollLeft is editor.getScrollLeft()
return if @updateRequested or scrollLeft is editor.getScrollLeft()
animationFramePending = @pendingScrollLeft?
@pendingScrollLeft = scrollLeft