Ensure .lines div is always at least the height of the scroll view

This ensures that the wrap guide extends the entire height of the
editor.
This commit is contained in:
Kevin Sawicki & Nathan Sobo
2014-05-21 19:07:03 -06:00
parent a8538a1361
commit 45eeee9aea
4 changed files with 20 additions and 6 deletions

View File

@@ -90,6 +90,14 @@ describe "EditorComponent", ->
expect(component.lineNodeForScreenRow(3).offsetTop).toBe 3 * lineHeightInPixels
expect(component.lineNodeForScreenRow(4).offsetTop).toBe 4 * lineHeightInPixels
it "renders the .lines div at the full height of the editor if there aren't enough lines to scroll vertically", ->
editor.setText('')
node.style.height = '300px'
component.measureHeightAndWidth()
linesNode = node.querySelector('.lines')
expect(linesNode.offsetHeight).toBe 300
describe "when showInvisibles is enabled", ->
invisibles = null

View File

@@ -42,6 +42,7 @@ EditorComponent = React.createClass
scrollWidth = editor.getScrollWidth()
scrollTop = editor.getScrollTop()
scrollLeft = editor.getScrollLeft()
scrollViewHeight = editor.getHeight()
lineHeightInPixels = editor.getLineHeight()
horizontalScrollbarHeight = editor.getHorizontalScrollbarHeight()
verticalScrollbarWidth = editor.getVerticalScrollbarWidth()
@@ -64,7 +65,7 @@ EditorComponent = React.createClass
scrollTop, scrollLeft, scrollHeight, scrollWidth, @scrollingVertically,
@cursorsMoved, @selectionChanged, @selectionAdded, cursorBlinkPeriod,
cursorBlinkResumeDelay, @onInputFocused, @onInputBlurred, @mouseWheelScreenRow,
invisibles
invisibles, scrollViewHeight
}
ScrollbarComponent

View File

@@ -17,7 +17,7 @@ EditorScrollViewComponent = React.createClass
render: ->
{editor, fontSize, fontFamily, lineHeight, showIndentGuide, invisibles} = @props
{renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollHeight, scrollWidth, scrollingVertically, mouseWheelScreenRow} = @props
{renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollHeight, scrollWidth, scrollViewHeight, scrollingVertically, mouseWheelScreenRow} = @props
{selectionChanged, selectionAdded, cursorBlinkPeriod, cursorBlinkResumeDelay, cursorsMoved, onInputFocused, onInputBlurred} = @props
if @isMounted()
@@ -37,7 +37,8 @@ EditorScrollViewComponent = React.createClass
LinesComponent {
ref: 'lines', editor, fontSize, fontFamily, lineHeight, showIndentGuide,
renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollingVertically,
selectionChanged, scrollHeight, scrollWidth, mouseWheelScreenRow, invisibles
selectionChanged, scrollHeight, scrollWidth, mouseWheelScreenRow, invisibles,
scrollViewHeight
}
componentDidMount: ->

View File

@@ -15,9 +15,10 @@ LinesComponent = React.createClass
render: ->
if @isMounted()
{editor, scrollTop, scrollLeft, scrollHeight, scrollWidth, lineHeight} = @props
{editor, scrollTop, scrollLeft, scrollHeight, scrollWidth, lineHeight, scrollViewHeight} = @props
style =
height: scrollHeight
height: Math.max(scrollHeight, scrollViewHeight)
width: scrollWidth
WebkitTransform: "translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)"
@@ -35,7 +36,10 @@ LinesComponent = React.createClass
shouldComponentUpdate: (newProps) ->
return true if newProps.selectionChanged
return true unless isEqualForProperties(newProps, @props, 'renderedRowRange', 'fontSize', 'fontFamily', 'lineHeight', 'scrollTop', 'scrollLeft', 'showIndentGuide', 'scrollingVertically', 'invisibles')
return true unless isEqualForProperties(newProps, @props,
'renderedRowRange', 'fontSize', 'fontFamily', 'lineHeight', 'scrollTop', 'scrollLeft',
'showIndentGuide', 'scrollingVertically', 'invisibles', 'scrollViewHeight'
)
{renderedRowRange, pendingChanges} = newProps
for change in pendingChanges