Revert "Don't obscure the last line of the editor with the horizontal scrollbar"

This reverts commit babbdbf9e5.
This commit is contained in:
Nathan Sobo
2014-04-23 14:03:33 -06:00
parent babbdbf9e5
commit 1d634e471e
2 changed files with 4 additions and 34 deletions

View File

@@ -1,4 +1,4 @@
{extend, flatten, toArray, last} = require 'underscore-plus'
{extend, flatten, toArray} = require 'underscore-plus'
ReactEditorView = require '../src/react-editor-view'
nbsp = String.fromCharCode(160)
@@ -526,25 +526,6 @@ describe "EditorComponent", ->
expect(editor.getScrollLeft()).toBe 100
it "does not obscure the last line with the horizontal scrollbar", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 10 * charWidth + 'px'
component.measureHeightAndWidth()
editor.setScrollBottom(editor.getScrollHeight())
lastLineNode = last(node.querySelectorAll('.line'))
bottomOfLastLine = lastLineNode.getBoundingClientRect().bottom
topOfHorizontalScrollbar = horizontalScrollbarNode.getBoundingClientRect().top
expect(bottomOfLastLine).toBe topOfHorizontalScrollbar
# Render no space below the last line when there's no horizontal scrollbar
node.style.width = 100 * charWidth + 'px'
component.measureHeightAndWidth()
editor.setScrollBottom(editor.getScrollHeight())
lastLineNode = last(node.querySelectorAll('.line'))
bottomOfLastLine = lastLineNode.getBoundingClientRect().bottom
bottomOfEditor = node.getBoundingClientRect().bottom
expect(bottomOfLastLine).toBe bottomOfEditor
describe "when a mousewheel event occurs on the editor", ->
it "updates the horizontal or vertical scrollbar depending on which delta is greater (x or y)", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'

View File

@@ -114,17 +114,6 @@ class DisplayBuffer extends Model
getHeight: -> @height ? @getScrollHeight()
setHeight: (@height) -> @height
getClientHeight: ->
if @horizontallyScrollable()
@getHeight() - @getHorizontalScrollbarHeight()
else
@getHeight()
horizontallyScrollable: ->
not @getSoftWrap() and @getScrollWidth() > @getWidth()
getHorizontalScrollbarHeight: -> 15
getWidth: -> @width ? @getScrollWidth()
setWidth: (newWidth) ->
oldWidth = @width
@@ -135,13 +124,13 @@ class DisplayBuffer extends Model
getScrollTop: -> @scrollTop
setScrollTop: (scrollTop) ->
if @manageScrollPosition
@scrollTop = Math.max(0, Math.min(@getScrollHeight() - @getClientHeight(), scrollTop))
@scrollTop = Math.max(0, Math.min(@getScrollHeight() - @getHeight(), scrollTop))
else
@scrollTop = scrollTop
getScrollBottom: -> @scrollTop + @height
setScrollBottom: (scrollBottom) ->
@setScrollTop(scrollBottom - @getClientHeight())
@setScrollTop(scrollBottom - @height)
@getScrollBottom()
getScrollLeft: -> @scrollLeft
@@ -195,7 +184,7 @@ class DisplayBuffer extends Model
unless @getLineHeight() > 0
throw new Error("You must assign a non-zero lineHeight before calling ::getVisibleRowRange()")
heightInLines = Math.ceil(@getClientHeight() / @getLineHeight()) + 1
heightInLines = Math.ceil(@getHeight() / @getLineHeight()) + 1
startRow = Math.floor(@getScrollTop() / @getLineHeight())
endRow = Math.min(@getLineCount(), Math.ceil(startRow + heightInLines))
[startRow, endRow]