mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Make it more obvious that Editor's scroll methods take pixelPositions
This commit is contained in:
parent
2e9bef04a9
commit
6ad50b379f
@ -133,8 +133,8 @@ class Cursor extends View
|
||||
|
||||
updateAppearance: ->
|
||||
screenPosition = @getScreenPosition()
|
||||
position = @editor.pixelPositionForScreenPosition(screenPosition)
|
||||
@css(position)
|
||||
pixelPosition = @editor.pixelPositionForScreenPosition(screenPosition)
|
||||
@css(pixelPosition)
|
||||
|
||||
if this == _.last(@editor.getCursors())
|
||||
@editor.scrollTo(position)
|
||||
@editor.scrollTo(pixelPosition)
|
||||
|
@ -481,33 +481,33 @@ class Editor extends View
|
||||
getCurrentMode: ->
|
||||
@buffer.getMode()
|
||||
|
||||
scrollTo: (position) ->
|
||||
scrollTo: (pixelPosition) ->
|
||||
_.defer =>
|
||||
@scrollVertically(position)
|
||||
@scrollHorizontally(position)
|
||||
@scrollVertically(pixelPosition)
|
||||
@scrollHorizontally(pixelPosition)
|
||||
|
||||
scrollVertically: (position) ->
|
||||
scrollVertically: (pixelPosition) ->
|
||||
linesInView = @scroller.height() / @lineHeight
|
||||
maxScrollMargin = Math.floor((linesInView - 1) / 2)
|
||||
scrollMargin = Math.min(@vScrollMargin, maxScrollMargin)
|
||||
margin = scrollMargin * @lineHeight
|
||||
desiredTop = position.top - margin
|
||||
desiredBottom = position.top + @lineHeight + margin
|
||||
desiredTop = pixelPosition.top - margin
|
||||
desiredBottom = pixelPosition.top + @lineHeight + margin
|
||||
|
||||
if desiredBottom > @scroller.scrollBottom()
|
||||
@scroller.scrollBottom(desiredBottom)
|
||||
else if desiredTop < @scroller.scrollTop()
|
||||
@scroller.scrollTop(desiredTop)
|
||||
|
||||
scrollHorizontally: (position) ->
|
||||
scrollHorizontally: (pixelPosition) ->
|
||||
return if @softWrap
|
||||
|
||||
charsInView = @scroller.width() / @charWidth
|
||||
maxScrollMargin = Math.floor((charsInView - 1) / 2)
|
||||
scrollMargin = Math.min(@hScrollMargin, maxScrollMargin)
|
||||
margin = scrollMargin * @charWidth
|
||||
desiredRight = position.left + @charWidth + margin
|
||||
desiredLeft = position.left - margin
|
||||
desiredRight = pixelPosition.left + @charWidth + margin
|
||||
desiredLeft = pixelPosition.left - margin
|
||||
|
||||
if desiredRight > @scroller.scrollRight()
|
||||
@scroller.scrollRight(desiredRight)
|
||||
|
Loading…
Reference in New Issue
Block a user