Preserve un-rounded scroll positions

This commit is contained in:
Antonio Scandurra
2015-09-23 17:40:48 +02:00
parent 7666e4b82e
commit baf27bf99a
2 changed files with 16 additions and 8 deletions

View File

@@ -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}

View File

@@ -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: ->