more scrolling fixes.

This commit is contained in:
Christopher Jeffrey 2015-01-14 16:24:55 -08:00
parent dafad57d0d
commit 6eb28b6b4f
1 changed files with 7 additions and 18 deletions

View File

@ -1436,25 +1436,14 @@ Screen.prototype._focus = function(self, old) {
// If we're in a scrollable element,
// automatically scroll to the focused element.
if (el) {
var ryi = self.top - el.top - el.itop
, ryl = self.top + self.height - el.top - el.ibottom
, visible = el.height - el.iheight;
if (ryi < el.childBase) {
el.scrollTo(ryi);
self.screen.render();
} else if (self.rtop + self.height > el.childBase + el.height - el.iheight) {
//} else if (self.rtop + self.height > el.childBase + el.height) {
var visible = self.screen.height - el.top - el.itop - el.bottom - el.ibottom;
if (self.rtop < el.childBase) {
el.scrollTo(self.rtop);
//el.scrollTo(self.rtop + self.height - el.height);
self.screen.render();
} else if (self.rtop + self.height - self.ibottom > el.childBase + visible) {
el.scrollTo(self.rtop - (visible - self.height));
self.screen.render();
}
//} else if (ryi >= el.childBase + visible) {
// el.scrollTo(ryi + self.height);
// self.screen.render();
//} else if (ryl >= el.childBase + visible) {
// el.scrollTo(ryi + self.height);
// self.screen.render();
//}
}
if (old) {
@ -3848,7 +3837,7 @@ ScrollableBox.prototype.setScroll =
ScrollableBox.prototype.scrollTo = function(offset) {
// XXX
// At first, this appeared to account for the first new calculation of childBase:
// this.scroll(0);
this.scroll(0);
return this.scroll(offset - (this.childBase + this.childOffset));
};