diff --git a/README.md b/README.md index 9af9f46..35ce92e 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/widget.js b/lib/widget.js index 6ace8e9..e391877 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -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) {