Use presenter’s scrollTop/scrollLeft in LinesComponent

This commit is contained in:
Nathan Sobo
2015-01-21 17:08:02 -07:00
parent f479e9d029
commit add3972477
2 changed files with 10 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ LinesComponent = React.createClass
{scrollWidth, scrollHeight} = @newState
{lineHeightInPixels, defaultCharWidth, scrollViewHeight, scopedCharacterWidthsChangeCount} = @props
{scrollTop, scrollLeft, cursorPixelRects} = @props
{cursorPixelRects} = @props
style =
height: Math.max(scrollHeight, scrollViewHeight)
width: scrollWidth
@@ -48,7 +48,8 @@ LinesComponent = React.createClass
}
getTransform: ->
{scrollTop, scrollLeft, useHardwareAcceleration} = @props
{scrollTop, scrollLeft} = @newState
{useHardwareAcceleration} = @props
if useHardwareAcceleration
"translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)"

View File

@@ -232,6 +232,7 @@ TextEditorComponent = React.createClass
clientHeight: editor.getHeight()
clientWidth: editor.getWidth()
scrollTop: editor.getScrollTop()
scrollLeft: editor.getScrollLeft()
lineHeight: editor.getLineHeightInPixels()
baseCharacterWidth: editor.getDefaultCharWidth()
lineOverdrawMargin: lineOverdrawMargin
@@ -393,7 +394,7 @@ TextEditorComponent = React.createClass
@subscribe editor.onDidChangeCharacterWidths(@onCharacterWidthsChanged)
@subscribe editor.onDidChangePlaceholderText(@onPlaceholderTextChanged)
@subscribe editor.$scrollTop.changes, @onScrollTopChanged
@subscribe editor.$scrollLeft.changes, @requestUpdate
@subscribe editor.$scrollLeft.changes, @onScrollLeftChanged
@subscribe editor.$verticalScrollbarWidth.changes, @requestUpdate
@subscribe editor.$horizontalScrollbarHeight.changes, @requestUpdate
@subscribe editor.$height.changes, @requestUpdate
@@ -530,6 +531,7 @@ TextEditorComponent = React.createClass
unless animationFramePending
@requestAnimationFrame =>
@props.editor.setScrollLeft(@pendingScrollLeft)
@presenter?.setScrollLeft(@pendingScrollLeft)
@pendingScrollLeft = null
onMouseWheel: (event) ->
@@ -725,6 +727,10 @@ TextEditorComponent = React.createClass
@onStoppedScrollingAfterDelay ?= debounce(@onStoppedScrolling, 200)
@onStoppedScrollingAfterDelay()
onScrollLeftChanged: ->
@presenter?.setScrollLeft(@props.editor.getScrollLeft())
@requestUpdate()
onStoppedScrolling: ->
return unless @isMounted()