mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user