fix shift+G. potentially use getScrollHeight for more things.

This commit is contained in:
Christopher Jeffrey 2015-05-01 16:44:10 -07:00
parent 0b5b04c739
commit b6c512925f
1 changed files with 15 additions and 2 deletions

View File

@ -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);
};