From baf27bf99a34db13e7d2750eef09d31e9147ef65 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 23 Sep 2015 17:40:48 +0200 Subject: [PATCH] Preserve un-rounded scroll positions --- src/text-editor-component.coffee | 8 ++++---- src/text-editor-presenter.coffee | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee index 4db79e716..ef2af790a 100644 --- a/src/text-editor-component.coffee +++ b/src/text-editor-component.coffee @@ -809,10 +809,10 @@ class TextEditorComponent {clientX, clientY} = event linesClientRect ?= @linesComponent.getDomNode().getBoundingClientRect() - top = clientY - linesClientRect.top + @presenter.scrollTop - left = clientX - linesClientRect.left + @presenter.scrollLeft - bottom = linesClientRect.top + @presenter.scrollTop + linesClientRect.height - clientY - right = linesClientRect.left + @presenter.scrollLeft + linesClientRect.width - clientX + top = clientY - linesClientRect.top + @presenter.getRealScrollTop() + left = clientX - linesClientRect.left + @presenter.getRealScrollLeft() + bottom = linesClientRect.top + @presenter.getRealScrollTop() + linesClientRect.height - clientY + right = linesClientRect.left + @presenter.getRealScrollLeft() + linesClientRect.width - clientX {top, left, bottom, right} diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 8dc9a90a9..9474e9c5f 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -830,6 +830,9 @@ class TextEditorPresenter getScrollTop: -> @scrollTop + getRealScrollTop: -> + @realScrollTop ? @scrollTop + didStartScrolling: -> if @stoppedScrollingTimeoutId? clearTimeout(@stoppedScrollingTimeoutId) @@ -865,6 +868,9 @@ class TextEditorPresenter getScrollLeft: -> @scrollLeft + getRealScrollLeft: -> + @realScrollLeft ? @scrollLeft + getClientHeight: -> if @clientHeight @clientHeight @@ -1542,15 +1548,17 @@ class TextEditorPresenter @setScrollRight(desiredScrollRight) commitPendingScrollLeftPosition: -> - scrollLeft = Math.round(@constrainScrollLeft(@pendingScrollLeft)) + scrollLeft = @constrainScrollLeft(@pendingScrollLeft) if scrollLeft isnt @scrollLeft and not Number.isNaN(scrollLeft) - @scrollLeft = scrollLeft + @realScrollLeft = scrollLeft + @scrollLeft = Math.round(scrollLeft) @model.setScrollLeft(@scrollLeft) commitPendingScrollTopPosition: -> - scrollTop = Math.round(@constrainScrollTop(@pendingScrollTop)) + scrollTop = @constrainScrollTop(@pendingScrollTop) if scrollTop isnt @scrollTop and not Number.isNaN(scrollTop) - @scrollTop = scrollTop + @realScrollTop = scrollTop + @scrollTop = Math.round(scrollTop) @model.setScrollTop(@scrollTop) updateScrollPosition: ->