diff --git a/lib/widget.js b/lib/widget.js index 20736f0..e70cc79 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -4224,6 +4224,8 @@ Element.prototype.render = function() { // Draw the scrollbar. // Could possibly draw this after all child elements. if (this.scrollbar) { + // XXX + // i = this.getScrollHeight(); i = Math.max(this._clines.length, this._scrollBottom()); } if (coords.notop || coords.nobot) i = -Infinity; @@ -4992,7 +4994,7 @@ function ScrollableBox(options) { return; } if (options.vi && key.name === 'g' && key.shift) { - self.scrollTo(self._scrollBottom()); + self.scrollTo(self.getScrollHeight()); self.screen.render(); return; } @@ -5013,7 +5015,7 @@ ScrollableBox.prototype.type = 'scrollable-box'; // XXX Potentially use this in place of scrollable checks elsewhere. ScrollableBox.prototype.__defineGetter__('reallyScrollable', function() { if (this.shrink) return this.scrollable; - return this._scrollBottom() > this.height; + return this.getScrollHeight() > this.height; }); ScrollableBox.prototype._scrollBottom = function() { @@ -5045,6 +5047,9 @@ ScrollableBox.prototype._scrollBottom = function() { return Math.max(current, el.rtop + el.height); }, 0); + // XXX Use this? Makes .getScrollHeight() useless! + // if (bottom < this._clines.length) bottom = this._clines.length; + if (this.lpos) this.lpos._scrollBottom = bottom; return bottom; @@ -5114,6 +5119,9 @@ ScrollableBox.prototype.scroll = function(offset, always) { // and put it in a scrollable text box. this.parseContent(); + // XXX + // max = this.getScrollHeight() - (this.height - this.iheight); + max = this._clines.length - (this.height - this.iheight); if (max < 0) max = 0; emax = this._scrollBottom() - (this.height - this.iheight); @@ -5159,6 +5167,9 @@ ScrollableBox.prototype._recalculateIndex = function() { return 0; } + // XXX + // max = this.getScrollHeight() - (this.height - this.iheight); + max = this._clines.length - (this.height - this.iheight); if (max < 0) max = 0; emax = this._scrollBottom() - (this.height - this.iheight); @@ -5205,6 +5216,8 @@ ScrollableBox.prototype.getScrollPerc = function(s) { }; ScrollableBox.prototype.setScrollPerc = function(i) { + // XXX + // var m = this.getScrollHeight(); var m = Math.max(this._clines.length, this._scrollBottom()); return this.scrollTo((i / 100) * m | 0); };