Scroll exactly as we did before tiling

Except that now we store the scrolling tile, instead of the scrolling
row.
This commit is contained in:
Antonio Scandurra
2015-05-11 09:42:04 +02:00
parent 9581202a77
commit a6e0fa6e91
3 changed files with 7 additions and 8 deletions

View File

@@ -354,6 +354,7 @@ class TextEditorComponent
event.preventDefault() unless previousScrollLeft is @presenter.getScrollLeft()
else
# Scrolling vertically
@presenter.setScrollingTileId(@tileIdForNode(event.target))
previousScrollTop = @presenter.getScrollTop()
@presenter.setScrollTop(previousScrollTop - Math.round(wheelDeltaY * @scrollSensitivity))
event.preventDefault() unless previousScrollTop is @presenter.getScrollTop()
@@ -728,11 +729,12 @@ class TextEditorComponent
lineNumberNodeForScreenRow: (screenRow) -> @gutterContainerComponent.getLineNumberGutterComponent().lineNumberNodeForScreenRow(screenRow)
screenRowForNode: (node) ->
tileIdForNode: (node) ->
while node?
if screenRow = node.dataset.screenRow
return parseInt(screenRow)
if tileId = node.dataset.tileId
return tileId
node = node.parentElement
null
getFontSize: ->

View File

@@ -905,7 +905,7 @@ class TextEditorPresenter
@emitDidUpdateState()
setScrollingTile: (tileId) ->
setScrollingTileId: (tileId) ->
if @scrollingTile isnt tileId
@scrollingTile = tileId
@didStartScrolling()

View File

@@ -21,14 +21,11 @@ class TileComponent
@screenRowsByLineId = {}
@lineIdsByScreenRow = {}
@domNode ?= document.createElement("div")
@domNode.addEventListener("mousewheel", @onMouseWheel)
@domNode.dataset.tileId = @id
@domNode.style.position = "absolute"
@domNode.style.display = "block"
@domNode.classList.add("tile")
onMouseWheel: =>
@presenter.setScrollingTile(@id)
getDomNode: ->
@domNode