Keep scrolling tile around for mousewheel

This commit is contained in:
Antonio Scandurra
2015-05-05 19:49:49 +02:00
parent 9aaa8b4833
commit 216b757ac0
3 changed files with 14 additions and 9 deletions

View File

@@ -354,7 +354,6 @@ class TextEditorComponent
event.preventDefault() unless previousScrollLeft is @presenter.getScrollLeft()
else
# Scrolling vertically
@presenter.setMouseWheelScreenRow(@screenRowForNode(event.target))
previousScrollTop = @presenter.getScrollTop()
@presenter.setScrollTop(previousScrollTop - Math.round(wheelDeltaY * @scrollSensitivity))
event.preventDefault() unless previousScrollTop is @presenter.getScrollTop()

View File

@@ -317,9 +317,11 @@ class TextEditorPresenter
visibleTilesIndexes = [startIndex...endIndex]
for index, tile of @state.content.tiles
unless index in visibleTilesIndexes
delete @state.content.tiles[index]
delete @linesPresentersByTileIndex[index]
continue if index is @scrollingTile
continue if index in visibleTilesIndexes
delete @state.content.tiles[index]
delete @linesPresentersByTileIndex[index]
for index in visibleTilesIndexes
presenter = @linesPresentersByTileIndex[index] ?= new LinesPresenter(@)
@@ -728,8 +730,8 @@ class TextEditorPresenter
didStopScrolling: ->
@state.content.scrollingVertically = false
if @mouseWheelScreenRow?
@mouseWheelScreenRow = null
if @scrollingTile?
@scrollingTile = null
@shouldUpdateTilesState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateCustomGutterDecorationState = true
@@ -895,9 +897,9 @@ class TextEditorPresenter
@emitDidUpdateState()
setMouseWheelScreenRow: (mouseWheelScreenRow) ->
unless @mouseWheelScreenRow is mouseWheelScreenRow
@mouseWheelScreenRow = mouseWheelScreenRow
setScrollingTile: (tileId) ->
if @scrollingTile isnt tileId
@scrollingTile = tileId
@didStartScrolling()
setBaseCharacterWidth: (baseCharacterWidth) ->

View File

@@ -21,9 +21,13 @@ class TileComponent
@screenRowsByLineId = {}
@lineIdsByScreenRow = {}
@domNode = document.createElement("div")
@domNode.addEventListener("mousewheel", @onMouseWheel)
@domNode.style.position = "absolute"
@domNode.classList.add("tile")
onMouseWheel: =>
@presenter.setScrollingTile(@id)
getDomNode: ->
@domNode