Update the gutter if the scrollTop has changed

This commit is contained in:
Nathan Sobo
2014-04-15 17:18:11 -06:00
parent b96abfffb7
commit addbe80e8a
2 changed files with 6 additions and 4 deletions

View File

@@ -22,12 +22,13 @@ EditorCompont = React.createClass
{focused, fontSize, lineHeight, fontFamily, showIndentGuide} = @state
{editor, cursorBlinkPeriod, cursorBlinkResumeDelay} = @props
visibleRowRange = @getVisibleRowRange()
scrollTop = editor.getScrollTop()
className = 'editor react'
className += ' is-focused' if focused
div className: className, style: {fontSize, lineHeight, fontFamily}, tabIndex: -1, onFocus: @onFocus,
GutterComponent({editor, visibleRowRange})
GutterComponent({editor, visibleRowRange, scrollTop})
EditorScrollViewComponent {
ref: 'scrollView', editor, visibleRowRange, @onInputFocused, @onInputBlurred

View File

@@ -9,7 +9,7 @@ GutterComponent = React.createClass
mixins: [SubscriberMixin]
render: ->
{editor, visibleRowRange} = @props
{editor, visibleRowRange, scrollTop} = @props
[startRow, endRow] = visibleRowRange
lineHeightInPixels = editor.getLineHeight()
precedingHeight = startRow * lineHeightInPixels
@@ -17,7 +17,7 @@ GutterComponent = React.createClass
maxDigits = editor.getLastBufferRow().toString().length
style =
height: editor.getScrollHeight()
WebkitTransform: "translateY(#{-editor.getScrollTop()}px)"
WebkitTransform: "translateY(#{-scrollTop}px)"
wrapCount = 0
lineNumbers = []
@@ -52,8 +52,9 @@ GutterComponent = React.createClass
# non-zero-delta change to the screen lines has occurred within the current
# visible row range.
shouldComponentUpdate: (newProps) ->
{visibleRowRange} = @props
{visibleRowRange, scrollTop} = @props
return true unless newProps.scrollTop is scrollTop
return true unless isEqual(newProps.visibleRowRange, visibleRowRange)
for change in @pendingChanges when change.screenDelta > 0 or change.bufferDelta > 0