Add TextEditorElement::getMaxScrollTop

This commit is contained in:
Antonio Scandurra
2015-10-20 08:36:27 +02:00
parent ec9d1231aa
commit 40e3b08a8c
4 changed files with 37 additions and 0 deletions

View File

@@ -421,6 +421,9 @@ class TextEditorComponent
getScrollWidth: ->
@presenter.getScrollWidth()
getMaxScrollTop: ->
@presenter.getMaxScrollTop()
getVerticalScrollbarWidth: ->
@presenter.getVerticalScrollbarWidth()

View File

@@ -210,6 +210,12 @@ class TextEditorElement extends HTMLElement
getDefaultCharacterWidth: ->
@getModel().getDefaultCharWidth()
# Extended: Get the maximum scroll top that can be applied to this element.
#
# Returns a {Number} of pixels.
getMaxScrollTop: ->
@component?.getMaxScrollTop()
# Extended: Converts a buffer position to a pixel position.
#
# * `bufferPosition` An object that represents a buffer position. It can be either

View File

@@ -982,6 +982,13 @@ class TextEditorPresenter
getScrollWidth: ->
@scrollWidth
getMaxScrollTop: ->
scrollHeight = @getScrollHeight()
clientHeight = @getClientHeight()
return 0 unless scrollHeight? and clientHeight?
scrollHeight - clientHeight
setHorizontalScrollbarHeight: (horizontalScrollbarHeight) ->
unless @measuredHorizontalScrollbarHeight is horizontalScrollbarHeight
oldHorizontalScrollbarHeight = @measuredHorizontalScrollbarHeight