cleanup scroll code.
This commit is contained in:
parent
8ea1fe4dab
commit
efbae0c203
|
@ -2633,12 +2633,11 @@ Element.prototype._getCoords = function(get) {
|
|||
, xl = xi + this._getWidth(get)
|
||||
, yi = this._getTop(get)
|
||||
, yl = yi + this._getHeight(get)
|
||||
, ryi
|
||||
, ryl
|
||||
, visible
|
||||
, coords
|
||||
, v
|
||||
, base;
|
||||
, base
|
||||
, notop
|
||||
, nobot;
|
||||
|
||||
// Find a scrollable ancestor if we have one.
|
||||
var el = this;
|
||||
|
@ -2652,16 +2651,6 @@ Element.prototype._getCoords = function(get) {
|
|||
coords = this._getShrink(xi, xl, yi, yl);
|
||||
xi = coords.xi, xl = coords.xl;
|
||||
yi = coords.yi, yl = coords.yl;
|
||||
var p = this.screen.program;
|
||||
if (this.content === 'foo') {
|
||||
p.sc();
|
||||
p.cup(1, 0);
|
||||
p.el();
|
||||
p.write(JSON.stringify({
|
||||
yi: yi, yl: yl
|
||||
}));
|
||||
p.rc();
|
||||
}
|
||||
}
|
||||
|
||||
// Check to make sure we're visible and
|
||||
|
@ -2669,30 +2658,7 @@ Element.prototype._getCoords = function(get) {
|
|||
// NOTE: Lists have a property where only
|
||||
// the list items are obfuscated.
|
||||
if (el && (!el.items || ~el.items.indexOf(this))) {
|
||||
// This is unfortunate because this._getTop(true) is based on its
|
||||
// this.parent.lpos.yi - which was saved after it's render() **with the
|
||||
// childBase subtracted!!!!*** This means nested elements within
|
||||
// a scrollable box are screwy unless we do this.
|
||||
// We only do this when `get` is true, because that gets this.parent.lpos.
|
||||
// If it's false, the parent's position is calculated on the spot.
|
||||
var _cb = el.childBase;
|
||||
if (0) if (get) {
|
||||
yi += this.parent.lpos._cb; // childbase of main scrollable element.
|
||||
yl += this.parent.lpos._cb;
|
||||
}
|
||||
|
||||
var _el = this;
|
||||
if (0) while (_el = _el.parent) {
|
||||
if (_el.scrollable) {
|
||||
yi -= _el.childBase;
|
||||
yl -= _el.childBase;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.parent.scrollable) {
|
||||
//yi -= this.parent.childBase;
|
||||
//yl -= this.parent.childBase;
|
||||
yi -= this.parent.lpos.base;
|
||||
yl -= this.parent.lpos.base;
|
||||
}
|
||||
|
@ -2703,6 +2669,7 @@ Element.prototype._getCoords = function(get) {
|
|||
return;
|
||||
} else {
|
||||
// Is partially covered below.
|
||||
notop = true;
|
||||
v = (this.parent.lpos.yi + this.parent.itop) - yi;
|
||||
base = (this.childBase || 0) + v;
|
||||
yi += v;
|
||||
|
@ -2713,6 +2680,7 @@ Element.prototype._getCoords = function(get) {
|
|||
return;
|
||||
} else {
|
||||
// Is partially covered below.
|
||||
nobot = true;
|
||||
v = yl - (this.parent.lpos.yl - this.parent.ibottom);
|
||||
yl -= v;
|
||||
}
|
||||
|
@ -2720,21 +2688,6 @@ Element.prototype._getCoords = function(get) {
|
|||
|
||||
// Shouldn't be necessary.
|
||||
if (yi >= yl) return;
|
||||
|
||||
var p = this.screen.program;
|
||||
if (this.content === 'foo') {
|
||||
p.sc();
|
||||
p.cup(0, 0);
|
||||
p.el();
|
||||
p.write(JSON.stringify({
|
||||
yi: yi, yl: yl,
|
||||
//pyi: this.parent.lpos.yi,
|
||||
//pyl: this.parent.lpos.yl,
|
||||
//cb: el.childBase,
|
||||
//pcb: this.parent.lpos._cb
|
||||
}));
|
||||
p.rc();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -2742,25 +2695,23 @@ Element.prototype._getCoords = function(get) {
|
|||
xl: xl,
|
||||
yi: yi,
|
||||
yl: yl,
|
||||
_cb: _cb || 0,
|
||||
base: base || this.childBase || 0,
|
||||
notop: ryi != null && ryi < el.childBase,
|
||||
nobot: ryl != null && ryl > el.childBase + visible
|
||||
notop: notop,
|
||||
nobot: nobot
|
||||
};
|
||||
};
|
||||
|
||||
// Here be dragons.
|
||||
Element.prototype.render = function() {
|
||||
this.emit('prerender');
|
||||
|
||||
this.parseContent();
|
||||
|
||||
var coords = this._getCoords(true);
|
||||
if (!coords) return;
|
||||
|
||||
//if (!coords) {
|
||||
// delete this.lpos;
|
||||
// return;
|
||||
//}
|
||||
if (!coords) {
|
||||
delete this.lpos;
|
||||
return;
|
||||
}
|
||||
|
||||
var lines = this.screen.lines
|
||||
, xi = coords.xi
|
||||
|
|
|
@ -59,7 +59,7 @@ var box2 = blessed.box({
|
|||
top: 20,
|
||||
width: '80%',
|
||||
height: 9,
|
||||
border_: {
|
||||
border: {
|
||||
type: 'ascii'
|
||||
},
|
||||
style: {
|
||||
|
@ -82,18 +82,18 @@ var box2 = blessed.box({
|
|||
|
||||
var box3 = blessed.box({
|
||||
parent: box2,
|
||||
//scrollable: true,
|
||||
scrollable: true,
|
||||
//content: 'foo1\nfoo2\nfoo3\nfoo4\nfoo5\nfoo6\nfoo7\nf008',
|
||||
//left: 'center',
|
||||
left: 2,
|
||||
top: 2,
|
||||
left: 3,
|
||||
top: 3,
|
||||
content: 'foo',
|
||||
shrink: true,
|
||||
//height: 2,
|
||||
//width: 3,
|
||||
//shrink: true,
|
||||
height: 4,
|
||||
width: 5,
|
||||
//width: '80%',
|
||||
//height: 5,
|
||||
border_: {
|
||||
border: {
|
||||
type: 'ascii'
|
||||
},
|
||||
style: {
|
||||
|
|
Loading…
Reference in New Issue