fix scrolling glitch.
This commit is contained in:
parent
73939984b4
commit
b8f1241bca
|
@ -3243,7 +3243,8 @@ ScrollableBox.prototype.scroll = function(offset, always) {
|
||||||
, i
|
, i
|
||||||
, max
|
, max
|
||||||
, emax
|
, emax
|
||||||
, t;
|
, t
|
||||||
|
, l;
|
||||||
|
|
||||||
if (diff === 0) {
|
if (diff === 0) {
|
||||||
return this.emit('scroll');
|
return this.emit('scroll');
|
||||||
|
@ -3257,6 +3258,7 @@ ScrollableBox.prototype.scroll = function(offset, always) {
|
||||||
max = this._clines.length - (this.height - this.iheight);
|
max = this._clines.length - (this.height - this.iheight);
|
||||||
if (max < 0) max = 0;
|
if (max < 0) max = 0;
|
||||||
emax = this._scrollBottom() - (this.height - this.iheight);
|
emax = this._scrollBottom() - (this.height - this.iheight);
|
||||||
|
if (emax < 0) emax = 0;
|
||||||
|
|
||||||
this.childBase = Math.min(this.childBase, Math.max(emax, max));
|
this.childBase = Math.min(this.childBase, Math.max(emax, max));
|
||||||
diff = this.childBase - base;
|
diff = this.childBase - base;
|
||||||
|
@ -3268,13 +3270,13 @@ ScrollableBox.prototype.scroll = function(offset, always) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff > 0) {
|
if (diff > 0) {
|
||||||
for (i = base; i < this.childBase; i++) {
|
l = Math.min(this.childBase, this._clines.length);
|
||||||
if (!this._clines[i]) continue;
|
for (i = base; i < l; i++) {
|
||||||
this.contentIndex += this._clines[i].length + 1;
|
this.contentIndex += this._clines[i].length + 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = base - 1; i >= this.childBase; i--) {
|
l = Math.min(this.childBase, this._clines.length);
|
||||||
if (!this._clines[i]) continue;
|
for (i = base - 1; i >= l; i--) {
|
||||||
this.contentIndex -= this._clines[i].length + 1;
|
this.contentIndex -= this._clines[i].length + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3300,9 +3302,9 @@ ScrollableBox.prototype.scroll = function(offset, always) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ScrollableBox.prototype._recalculateIndex = function() {
|
ScrollableBox.prototype._recalculateIndex = function() {
|
||||||
var max, emax, i, t;
|
var max, emax, i, t, l;
|
||||||
|
|
||||||
if (this.detached || !this.scrollabe) {
|
if (this.detached || !this.scrollable) {
|
||||||
this.contentIndex = 0;
|
this.contentIndex = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3310,6 +3312,7 @@ ScrollableBox.prototype._recalculateIndex = function() {
|
||||||
max = this._clines.length - (this.height - this.iheight);
|
max = this._clines.length - (this.height - this.iheight);
|
||||||
if (max < 0) max = 0;
|
if (max < 0) max = 0;
|
||||||
emax = this._scrollBottom() - (this.height - this.iheight);
|
emax = this._scrollBottom() - (this.height - this.iheight);
|
||||||
|
if (emax < 0) emax = 0;
|
||||||
|
|
||||||
this.childBase = Math.min(this.childBase, Math.max(emax, max));
|
this.childBase = Math.min(this.childBase, Math.max(emax, max));
|
||||||
|
|
||||||
|
@ -3319,8 +3322,8 @@ ScrollableBox.prototype._recalculateIndex = function() {
|
||||||
this.childBase = this.baseLimit;
|
this.childBase = this.baseLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, t = 0; i < this.childBase; i++) {
|
l = Math.min(this.childBase, this._clines.length);
|
||||||
if (!this._clines[i]) continue;
|
for (i = 0, t = 0; i < l; i++) {
|
||||||
t += this._clines[i].length + 1;
|
t += this._clines[i].length + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4215,8 +4218,8 @@ Textarea.prototype._listener = function(ch, key) {
|
||||||
|
|
||||||
Textarea.prototype._typeScroll = function() {
|
Textarea.prototype._typeScroll = function() {
|
||||||
// XXX Workaround
|
// XXX Workaround
|
||||||
var width = this.height - this.iheight;
|
var height = this.height - this.iheight;
|
||||||
if (this._clines.length - this.childBase > width) {
|
if (this._clines.length - this.childBase > height) {
|
||||||
//this.setContent(this.value + '\n');
|
//this.setContent(this.value + '\n');
|
||||||
this.scroll(this._clines.length);
|
this.scroll(this._clines.length);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue