add getScrollHeight. fixes #16.

This commit is contained in:
Christopher Jeffrey 2013-08-20 13:34:18 -05:00
parent b280a3c320
commit 38f234aa91
2 changed files with 12 additions and 3 deletions

View File

@ -477,12 +477,17 @@ A box with scrollable content.
- inherits all from Box.
- **scroll** - received when the element is scrolled.
- **resetScroll** - reset scroll offset to zero.
##### Methods:
- **scroll(offset)** - scroll the content by an offset.
- **scroll(offset)** - scroll the content by a relative offset.
- **scrollTo(index)** - scroll the content to an absolute index.
- **setScroll(index)** - same as `scrollTo`.
- **setScrollPerc(perc)** - set the current scroll index in percentage (0-100).
- **getScroll()** - get the current scroll index in lines.
- **getScrollHeight()** - get the actual height of the scrolling area.
- **getScrollPerc()** - get the current scroll index in percentage.
- **resetScroll()** - reset the scroll index to its initial state.
#### ScrollableText (from ScrollableBox)

View File

@ -3856,12 +3856,16 @@ ScrollableBox.prototype.resetScroll = function() {
return this.emit('scroll');
};
ScrollableBox.prototype.getScrollHeight = function(s) {
return Math.max(this._clines.length, this._scrollBottom());
};
ScrollableBox.prototype.getScrollPerc = function(s) {
var pos = this.lpos || this._getCoords();
if (!pos) return s ? -1 : 0;
var height = (pos.yl - pos.yi) - this.iheight
, i = Math.max(this._clines.length, this._scrollBottom())
, i = this.getScrollHeight()
, p;
if (height < i) {