mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-11 03:25:45 +00:00
fix nested scrollable elements.
This commit is contained in:
parent
19dd8a47d0
commit
ea857ea550
@ -2659,11 +2659,20 @@ Element.prototype._getCoords = function(get) {
|
|||||||
// If it's false, the parent's position is calculated on the spot.
|
// If it's false, the parent's position is calculated on the spot.
|
||||||
var _cb = el.childBase;
|
var _cb = el.childBase;
|
||||||
if (get) {
|
if (get) {
|
||||||
yi += this.parent.lpos._cb;
|
yi += this.parent.lpos._cb; // childbase of main scrollable element.
|
||||||
yl += this.parent.lpos._cb;
|
yl += this.parent.lpos._cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
ryi = yi - el._getTop(get) - el.itop;
|
if (0) if (get) {
|
||||||
|
var _el = this;
|
||||||
|
while (_el = _el.parent) {
|
||||||
|
if (!_el.lpos) continue;
|
||||||
|
yi += _el.lpos._cb;
|
||||||
|
yl += _el.lpos._cb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ryi = yi - el._getTop(get) - el.itop; // maybe plus
|
||||||
ryl = yl - el._getTop(get) - el.ibottom;
|
ryl = yl - el._getTop(get) - el.ibottom;
|
||||||
visible = el._getHeight(get) - el.iheight;
|
visible = el._getHeight(get) - el.iheight;
|
||||||
|
|
||||||
@ -2687,8 +2696,28 @@ Element.prototype._getCoords = function(get) {
|
|||||||
yl = yi + v;
|
yl = yi + v;
|
||||||
}
|
}
|
||||||
|
|
||||||
yi -= el.childBase;
|
//yi -= el.childBase;
|
||||||
yl -= el.childBase;
|
//yl -= el.childBase;
|
||||||
|
|
||||||
|
var _el = this;
|
||||||
|
while (_el = _el.parent) {
|
||||||
|
if (_el.scrollable) {
|
||||||
|
yi -= _el.childBase;
|
||||||
|
yl -= _el.childBase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var p = this.screen.program;
|
||||||
|
if (this.content === 'foo') {
|
||||||
|
p.sc();
|
||||||
|
p.cup(p.rows - 1, 0);
|
||||||
|
p.write(JSON.stringify({
|
||||||
|
yi: yi, yl: yl, ryi: ryi, ryl: ryl,
|
||||||
|
cb: el.childBase,
|
||||||
|
pcb: this.parent.lpos._cb
|
||||||
|
}));
|
||||||
|
p.rc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to shrink the element base on the
|
// Attempt to shrink the element base on the
|
||||||
|
@ -54,11 +54,43 @@ var text2 = blessed.box({
|
|||||||
var box2 = blessed.box({
|
var box2 = blessed.box({
|
||||||
parent: box,
|
parent: box,
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
content: 'foo1\nfoo2\nfoo3\nfoo4\nfoo5\nfoo6\nfoo7\nf008',
|
content: 'foo-one\nfoo-two',
|
||||||
left: 'center',
|
left: 'center',
|
||||||
top: 20,
|
top: 20,
|
||||||
width: '80%',
|
width: '80%',
|
||||||
height: 5,
|
height: 9,
|
||||||
|
border: {
|
||||||
|
type: 'ascii'
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
bg: 'magenta',
|
||||||
|
focus: {
|
||||||
|
bg: 'blue'
|
||||||
|
},
|
||||||
|
hover: {
|
||||||
|
bg: 'red'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
keys: true,
|
||||||
|
vi: true,
|
||||||
|
alwaysScroll: true,
|
||||||
|
scrollbar_: {
|
||||||
|
ch: ' ',
|
||||||
|
inverse: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var box3 = blessed.box({
|
||||||
|
parent: box2,
|
||||||
|
//scrollable: true,
|
||||||
|
//content: 'foo1\nfoo2\nfoo3\nfoo4\nfoo5\nfoo6\nfoo7\nf008',
|
||||||
|
//left: 'center',
|
||||||
|
left: 2,
|
||||||
|
top: 2,
|
||||||
|
content: 'foo',
|
||||||
|
shrink: true,
|
||||||
|
//width: '80%',
|
||||||
|
//height: 5,
|
||||||
border: {
|
border: {
|
||||||
type: 'ascii'
|
type: 'ascii'
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user