From add3972477ccc48b46e7fcb106c01b7c1312dcfb Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jan 2015 17:08:02 -0700 Subject: [PATCH] =?UTF-8?q?Use=20presenter=E2=80=99s=20scrollTop/scrollLef?= =?UTF-8?q?t=20in=20LinesComponent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lines-component.coffee | 5 +++-- src/text-editor-component.coffee | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lines-component.coffee b/src/lines-component.coffee index c2bd8e22a..ad3c221be 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -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)" diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee index e1d26fa70..d25713447 100644 --- a/src/text-editor-component.coffee +++ b/src/text-editor-component.coffee @@ -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()