From fd603a0cbcbd9dcc599564aae2858391a59f29f1 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sat, 14 Feb 2015 09:33:03 -0700 Subject: [PATCH] Move new character measurement to end of full update to avoid reflow --- src/lines-component.coffee | 4 +--- src/text-editor-component.coffee | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lines-component.coffee b/src/lines-component.coffee index f15ad9fd0..d6498772d 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -49,7 +49,7 @@ class LinesComponent @updateSync(visible) - updateSync: (visible) -> + updateSync: -> @newState = @presenter.state.content @oldState ?= {lines: {}} @@ -81,8 +81,6 @@ class LinesComponent @domNode.style.width = @newState.scrollWidth + 'px' @oldState.scrollWidth = @newState.scrollWidth - @measureCharactersInNewLines() if visible and not @newState.scrollingVertically - @cursorsComponent.updateSync() @highlightsComponent.updateSync() diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee index 784748f36..663e08a19 100644 --- a/src/text-editor-component.coffee +++ b/src/text-editor-component.coffee @@ -101,7 +101,7 @@ TextEditorComponent = React.createClass @hiddenInputComponent = new InputComponent(@presenter) scrollViewNode.appendChild(@hiddenInputComponent.domNode) - @linesComponent = new LinesComponent({@presenter, hostElement, useShadowDOM, visible: @isVisible()}) + @linesComponent = new LinesComponent({@presenter, hostElement, useShadowDOM}) scrollViewNode.appendChild(@linesComponent.domNode) @horizontalScrollbarComponent = new ScrollbarComponent({@presenter, orientation: 'horizontal', onScroll: @onHorizontalScroll}) @@ -153,7 +153,7 @@ TextEditorComponent = React.createClass @gutterComponent = null @hiddenInputComponent.updateSync() - @linesComponent.updateSync(@isVisible()) + @linesComponent.updateSync() @horizontalScrollbarComponent.updateSync() @verticalScrollbarComponent.updateSync() @scrollbarCornerComponent.updateSync() @@ -165,6 +165,8 @@ TextEditorComponent = React.createClass @props.hostElement.__spacePenView.trigger 'selection:changed' if selectionChanged @props.hostElement.__spacePenView.trigger 'editor:display-updated' + @linesComponent.measureCharactersInNewLines() if @isVisible() and not @newState.content.scrollingVertically + mountGutterComponent: -> {editor} = @props @gutterComponent = new GutterComponent({@presenter, editor, onMouseDown: @onGutterMouseDown})