Relativize pixelPositionForScreenPosition.top

This commit makes the method return a `top` value which is relative to the
viewport. However, we still need to return an absolute value for `left` because
lines are moved horizontally through a single transform on their parent node.

I would prefer being consistent (i.e. make everything relative), but moving
every single tile to simulate scrolling, on the other hand, seems overkill and
it's not really intuitive given that we are not tiling horizontally.

/cc: @nathansobo
This commit is contained in:
Antonio Scandurra
2015-05-12 09:25:31 +02:00
parent a6dab4860c
commit 19a95651dc

View File

@@ -375,11 +375,11 @@ class TextEditorPresenter
else
screenPosition = decoration.getMarker().getHeadScreenPosition()
pixelPosition = @pixelPositionForScreenPosition(screenPosition, true, absolute: true)
pixelPosition = @pixelPositionForScreenPosition(screenPosition, true)
{scrollTop, scrollLeft} = @state.content
{scrollLeft} = @state.content
top = pixelPosition.top + @lineHeight - scrollTop
top = pixelPosition.top + @lineHeight
left = pixelPosition.left + @gutterWidth - scrollLeft
if overlayDimensions = @overlayDimensions[decoration.id]
@@ -963,7 +963,7 @@ class TextEditorPresenter
hasPixelPositionRequirements: ->
@lineHeight? and @baseCharacterWidth?
pixelPositionForScreenPosition: (screenPosition, clip=true, {absolute}={}) ->
pixelPositionForScreenPosition: (screenPosition, clip=true) ->
screenPosition = Point.fromObject(screenPosition)
screenPosition = @model.clipScreenPosition(screenPosition) if clip
@@ -993,7 +993,7 @@ class TextEditorPresenter
left += characterWidths[char] ? baseCharacterWidth unless char is '\0'
column += charLength
top -= @scrollTop unless absolute
top -= @scrollTop
{top, left}
hasPixelRectRequirements: ->