fix scrolling on widget-form.js.

This commit is contained in:
Christopher Jeffrey 2015-01-16 10:16:00 -08:00
parent 5300702e34
commit f445dd8765
1 changed files with 7 additions and 4 deletions

View File

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