mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Preserve the target when scrolling w/ mousewheel on editor lines
This commit is contained in:
@@ -62,7 +62,7 @@ EditorComponent = React.createClass
|
||||
lineHeight: lineHeightInPixels, renderedRowRange, @pendingChanges,
|
||||
scrollTop, scrollLeft, scrollHeight, scrollWidth, @scrollingVertically,
|
||||
@cursorsMoved, @selectionChanged, @selectionAdded, cursorBlinkResumeDelay,
|
||||
@onInputFocused, @onInputBlurred
|
||||
@onInputFocused, @onInputBlurred, @mouseWheelScreenRow
|
||||
}
|
||||
|
||||
ScrollbarComponent
|
||||
|
||||
@@ -17,7 +17,7 @@ EditorScrollViewComponent = React.createClass
|
||||
|
||||
render: ->
|
||||
{editor, fontSize, fontFamily, lineHeight, showIndentGuide} = @props
|
||||
{renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollHeight, scrollWidth, scrollingVertically} = @props
|
||||
{renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollHeight, scrollWidth, scrollingVertically, mouseWheelScreenRow} = @props
|
||||
{selectionChanged, selectionAdded, cursorBlinkResumeDelay, cursorsMoved, onInputFocused, onInputBlurred} = @props
|
||||
|
||||
if @isMounted()
|
||||
@@ -37,7 +37,7 @@ EditorScrollViewComponent = React.createClass
|
||||
LinesComponent {
|
||||
ref: 'lines', editor, fontSize, fontFamily, lineHeight, showIndentGuide,
|
||||
renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollingVertically,
|
||||
selectionChanged, scrollHeight, scrollWidth
|
||||
selectionChanged, scrollHeight, scrollWidth, mouseWheelScreenRow
|
||||
}
|
||||
|
||||
componentDidMount: ->
|
||||
|
||||
@@ -64,15 +64,17 @@ LinesComponent = React.createClass
|
||||
@appendOrUpdateVisibleLineNodes(visibleLines, startRow)
|
||||
|
||||
removeLineNodes: (visibleLines=[]) ->
|
||||
{mouseWheelScreenRow} = @props
|
||||
visibleLineIds = new Set
|
||||
visibleLineIds.add(line.id.toString()) for line in visibleLines
|
||||
node = @getDOMNode()
|
||||
for lineId, lineNode of @lineNodesByLineId when not visibleLineIds.has(lineId)
|
||||
delete @lineNodesByLineId[lineId]
|
||||
screenRow = @screenRowsByLineId[lineId]
|
||||
delete @lineIdsByScreenRow[screenRow] if @lineIdsByScreenRow[screenRow] is lineId
|
||||
delete @screenRowsByLineId[lineId]
|
||||
node.removeChild(lineNode)
|
||||
unless screenRow is mouseWheelScreenRow
|
||||
delete @lineNodesByLineId[lineId]
|
||||
delete @lineIdsByScreenRow[screenRow] if @lineIdsByScreenRow[screenRow] is lineId
|
||||
delete @screenRowsByLineId[lineId]
|
||||
node.removeChild(lineNode)
|
||||
|
||||
appendOrUpdateVisibleLineNodes: (visibleLines, startRow) ->
|
||||
{lineHeight} = @props
|
||||
@@ -112,7 +114,7 @@ LinesComponent = React.createClass
|
||||
{editor, mini, showIndentGuide, lineHeight} = @props
|
||||
{tokens, text, lineEnding, fold, isSoftWrapped, indentLevel} = line
|
||||
top = screenRow * lineHeight
|
||||
lineHTML = "<div class=\"line\" style=\"position: absolute; top: #{top}px;\">"
|
||||
lineHTML = "<div class=\"line\" style=\"position: absolute; top: #{top}px;\" data-screen-row=\"#{screenRow}\">"
|
||||
|
||||
if text is ""
|
||||
lineHTML += @buildEmptyLineInnerHTML(line)
|
||||
|
||||
Reference in New Issue
Block a user