mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-04 07:05:01 +00:00
refactor scrollbar. fix shrink comparisons.
This commit is contained in:
parent
e13f0ce5d4
commit
1ae6a19b35
@ -1959,8 +1959,7 @@ Box.prototype._getShrinkSize = function(content) {
|
||||
|
||||
Box.prototype._getShrinkBox = function(xi, xl, yi, yl) {
|
||||
if (!this.children.length) {
|
||||
// return { xi: xi, xl: xi, yi: yi, yl: yi };
|
||||
return { xi: Infinity, xl: 0, yi: Infinity, yl: 0 };
|
||||
return { xi: xi, xl: xi, yi: yi, yl: yi };
|
||||
}
|
||||
|
||||
var i, el, mxi = 0, mxl = 0, myi = 0, myl = 0;
|
||||
@ -2055,16 +2054,20 @@ Box.prototype._getShrink = function(xi, xl, yi, yl, content) {
|
||||
var shrinkBox = this._getShrinkBox(xi, xl, yi, yl)
|
||||
, shrinkContent = this._getShrinkContent(xi, xl, yi, yl, content);
|
||||
|
||||
if (this.options.left == null && this.options.right != null) {
|
||||
xi = Math.min(shrinkBox.xi, shrinkContent.xi);
|
||||
if (shrinkBox.xl - shrinkBox.xi > shrinkContent.xl - shrinkContent.xi) {
|
||||
xi = shrinkBox.xi;
|
||||
xl = shrinkBox.xl;
|
||||
} else {
|
||||
xl = Math.max(shrinkBox.xl, shrinkContent.xl);
|
||||
xi = shrinkContent.xi;
|
||||
xl = shrinkContent.xl;
|
||||
}
|
||||
|
||||
if (this.options.top == null && this.options.bottom != null) {
|
||||
yi = Math.min(shrinkBox.yi, shrinkContent.yi);
|
||||
if (shrinkBox.yl - shrinkBox.yi > shrinkContent.yl - shrinkContent.yi) {
|
||||
yi = shrinkBox.yi;
|
||||
yl = shrinkBox.yl;
|
||||
} else {
|
||||
yl = Math.max(shrinkBox.yl, shrinkContent.yl);
|
||||
yi = shrinkContent.yi;
|
||||
yl = shrinkContent.yl;
|
||||
}
|
||||
|
||||
// Add padding if we're shrinking.
|
||||
@ -2279,9 +2282,10 @@ Box.prototype.render = function(stop) {
|
||||
x = xl - 1;
|
||||
if (this.scrollbar.ignoreBorder && this.border) x++;
|
||||
if (this.selected == null) {
|
||||
// TODO: Fix this - doesn't work with lists (and possibly scrollabletext).
|
||||
y = i - (yl - yi) - (this.border ? 2 : 0) - this.padding * 2;
|
||||
y = yi + (((yl - yi) * (this.childBase / y)) | 0);
|
||||
// TODO: The scrollbar seems to disappear at
|
||||
// the bottom of a scrollable text box. Fix.
|
||||
i = i - (yl - yi);
|
||||
y = yi + (yl - yi) * (this.childBase / i) | 0;
|
||||
} else {
|
||||
y = this.selected / i;
|
||||
y = yi + ((yl - yi) * y | 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user