Put a decreasing z-index on line-numbers tiles

This commit is contained in:
Antonio Scandurra 2015-08-27 12:15:55 +02:00
parent ca285d3fe3
commit 9ea62673d2
3 changed files with 29 additions and 1 deletions

View File

@ -601,6 +601,28 @@ describe "TextEditorComponent", ->
expect(lineNode.offsetTop).toBe(top)
expect(lineNode.textContent).toBe(text)
it "renders tiles upper in the stack in front of the ones below", ->
wrapperNode.style.height = 6.5 * lineHeightInPixels + 'px'
component.measureDimensions()
nextAnimationFrame()
tilesNodes = componentNode.querySelector(".line-numbers").querySelectorAll(".tile")
expect(tilesNodes[0].style.zIndex).toBe("2")
expect(tilesNodes[1].style.zIndex).toBe("1")
expect(tilesNodes[2].style.zIndex).toBe("0")
verticalScrollbarNode.scrollTop = 1 * lineHeightInPixels
verticalScrollbarNode.dispatchEvent(new UIEvent('scroll'))
nextAnimationFrame()
tilesNodes = componentNode.querySelector(".line-numbers").querySelectorAll(".tile")
expect(tilesNodes[0].style.zIndex).toBe("3")
expect(tilesNodes[1].style.zIndex).toBe("2")
expect(tilesNodes[2].style.zIndex).toBe("1")
expect(tilesNodes[3].style.zIndex).toBe("0")
it "gives the line numbers container the same height as the wrapper node", ->
linesNode = componentNode.querySelector(".line-numbers")

View File

@ -42,6 +42,10 @@ class LineNumbersTileComponent
@domNode.style['-webkit-transform'] = "translate3d(0, #{@newTileState.top}px, 0px)"
@oldTileState.top = @newTileState.top
if @newTileState.zIndex isnt @oldTileState.zIndex
@domNode.style.zIndex = @newTileState.zIndex
@oldTileState.zIndex = @newTileState.zIndex
if @newState.maxLineNumberDigits isnt @oldState.maxLineNumberDigits
node.remove() for id, node of @lineNumberNodesById
@oldState.tiles[@id] = {lineNumbers: {}}

View File

@ -344,18 +344,20 @@ class TextEditorPresenter
tile.left = -@scrollLeft
tile.height = @tileSize * @lineHeight
tile.display = "block"
tile.zIndex = zIndex--
tile.zIndex = zIndex
tile.highlights ?= {}
gutterTile = @lineNumberGutter.tiles[startRow] ?= {}
gutterTile.top = startRow * @lineHeight - @scrollTop
gutterTile.height = @tileSize * @lineHeight
gutterTile.display = "block"
gutterTile.zIndex = zIndex
@updateLinesState(tile, startRow, endRow) if @shouldUpdateLinesState
@updateLineNumbersState(gutterTile, startRow, endRow) if @shouldUpdateLineNumbersState
visibleTiles[startRow] = true
zIndex--
if @mouseWheelScreenRow? and @model.tokenizedLineForScreenRow(@mouseWheelScreenRow)?
mouseWheelTile = @tileForRow(@mouseWheelScreenRow)