From f445dd8765e131dba9bf26906e432cc13c8dfd06 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 16 Jan 2015 10:16:00 -0800 Subject: [PATCH] fix scrolling on widget-form.js. --- lib/widget.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index f8e3908..d0bcf49 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -1418,12 +1418,15 @@ Screen.prototype._focus = function(self, old) { // If we're in a scrollable element, // automatically scroll to the focused element. if (el) { + // NOTE: This is different from the other "visible" values - it needs the + // visible height of the scrolling element itself, not the element within + // it. var visible = self.screen.height - el.top - el.itop - el.bottom - el.ibottom; if (self.rtop < el.childBase) { el.scrollTo(self.rtop); self.screen.render(); } else if (self.rtop + self.height - self.ibottom > el.childBase + visible) { - el.scrollTo(self.rtop + self.height); + el.scrollTo(self.rtop - (el.height - self.height), true); self.screen.render(); } } @@ -3817,11 +3820,11 @@ ScrollableBox.prototype._scrollBottom = function() { }; ScrollableBox.prototype.setScroll = -ScrollableBox.prototype.scrollTo = function(offset) { +ScrollableBox.prototype.scrollTo = function(offset, always) { // XXX // At first, this appeared to account for the first new calculation of childBase: this.scroll(0); - return this.scroll(offset - (this.childBase + this.childOffset)); + return this.scroll(offset - (this.childBase + this.childOffset), always); }; ScrollableBox.prototype.getScroll = function() { @@ -5803,7 +5806,7 @@ Message.prototype.display = function(text, time, callback) { if (this.scrollable) { this.screen.saveFocus(); this.focus(); - this.setScroll(0); + this.scrollTo(0); } this.show();