From 8f989eeadddd06762f229a37bfb6cfc5510fa9e3 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 27 Jul 2013 05:49:53 -0500 Subject: [PATCH] fix scrollbar arithmetic. --- lib/widget.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index c0df1fb..5d2832e 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2838,17 +2838,19 @@ Element.prototype.render = function() { // Draw the scrollbar. if (this.scrollbar) { - i = Math.max(this._clines.length + 1, - this._scrollBottom() + (yl - yi) + 1); + i = Math.max(this._clines.length, this._scrollBottom()); } if (coords.notop || coords.nobot) i = -Infinity; if (this.scrollbar && (yl - yi) < i) { - i -= yl - yi; x = xl - 1; if (this.scrollbar.ignoreBorder && this.border) x++; - y = this.childBase + this.childOffset; - y = y / i; + if (this.alwaysScroll) { + y = this.childBase / (i - (yl - yi)); + } else { + y = (this.childBase + this.childOffset) / i; + } y = yi + ((yl - yi) * y | 0); + if (y >= yl) y = yl - 1; cell = lines[y] && lines[y][x]; if (cell) { ch = this.scrollbar.ch || ' ';