make new scrollable code compatible with get=false. add fixed option.
This commit is contained in:
parent
2dc3146d1f
commit
69f5993735
|
@ -1577,10 +1577,7 @@ function Element(options) {
|
|||
options = options || {};
|
||||
|
||||
// Workaround to get a `scrollable` option.
|
||||
if (options.scrollable
|
||||
&& !this._ignore
|
||||
&& this.type !== 'scrollable-box'
|
||||
&& this.type !== 'scrollable-text') {
|
||||
if (options.scrollable && !this._ignore && this.type !== 'scrollable-box') {
|
||||
Object.getOwnPropertyNames(ScrollableBox.prototype).forEach(function(key) {
|
||||
if (key === 'type') return;
|
||||
Object.defineProperty(this, key,
|
||||
|
@ -1637,6 +1634,7 @@ function Element(options) {
|
|||
this.valign = options.valign || 'top';
|
||||
this.wrap = options.wrap !== false;
|
||||
this.shrink = options.shrink;
|
||||
this.fixed = options.fixed;
|
||||
|
||||
if (typeof options.padding === 'number' || !options.padding) {
|
||||
options.padding = {
|
||||
|
@ -1687,7 +1685,8 @@ function Element(options) {
|
|||
top: this.border ? 0 : -1,
|
||||
tags: this.parseTags,
|
||||
shrink: true,
|
||||
style: this.style.label
|
||||
style: this.style.label,
|
||||
fixed: true
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -2638,7 +2637,8 @@ Element.prototype._getCoords = function(get) {
|
|||
, coords
|
||||
, v
|
||||
, notop
|
||||
, nobot;
|
||||
, nobot
|
||||
, ppos;
|
||||
|
||||
// Attempt to shrink the element base on the
|
||||
// size of the content and child elements.
|
||||
|
@ -2657,38 +2657,43 @@ Element.prototype._getCoords = function(get) {
|
|||
// inside of the visible scroll area.
|
||||
// NOTE: Lists have a property where only
|
||||
// the list items are obfuscated.
|
||||
if (el && (!el.items || ~el.items.indexOf(this))) {
|
||||
if (el && !this.fixed) {
|
||||
ppos = get
|
||||
? this.parent.lpos
|
||||
: this.parent._getCoords();
|
||||
|
||||
if (this.parent.scrollable) {
|
||||
yi -= this.parent.lpos.base;
|
||||
yl -= this.parent.lpos.base;
|
||||
yi -= ppos.base;
|
||||
yl -= ppos.base;
|
||||
}
|
||||
|
||||
if (yi < this.parent.lpos.yi + this.parent.itop) {
|
||||
if (yl - 1 < this.parent.lpos.yi + this.parent.itop) {
|
||||
if (yi < ppos.yi + this.parent.itop) {
|
||||
if (yl - 1 < ppos.yi + this.parent.itop) {
|
||||
// Is above.
|
||||
return;
|
||||
} else {
|
||||
// Is partially covered above.
|
||||
notop = true;
|
||||
v = this.parent.lpos.yi - yi;
|
||||
v = ppos.yi - yi;
|
||||
v += this.parent.itop - this.itop;
|
||||
base += v;
|
||||
yi += v;
|
||||
}
|
||||
} else if (yl > this.parent.lpos.yl - this.parent.ibottom) {
|
||||
if (yi > this.parent.lpos.yl - 1 - this.parent.ibottom) {
|
||||
} else if (yl > ppos.yl - this.parent.ibottom) {
|
||||
if (yi > ppos.yl - 1 - this.parent.ibottom) {
|
||||
// Is below.
|
||||
return;
|
||||
} else {
|
||||
// Is partially covered below.
|
||||
nobot = true;
|
||||
v = yl - this.parent.lpos.yl;
|
||||
v = yl - ppos.yl;
|
||||
v += this.parent.ibottom - this.ibottom;
|
||||
yl -= v;
|
||||
}
|
||||
}
|
||||
|
||||
// Shouldn't be necessary.
|
||||
// assert.ok(yi < yl);
|
||||
if (yi >= yl) return;
|
||||
}
|
||||
|
||||
|
@ -3637,6 +3642,12 @@ function List(options) {
|
|||
self.childOffset = visible - 1;
|
||||
}
|
||||
});
|
||||
|
||||
this.on('adopt', function(el) {
|
||||
if (!~self.items.indexOf(el)) {
|
||||
el.fixed = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
List.prototype.__proto__ = Box.prototype;
|
||||
|
@ -3672,8 +3683,8 @@ List.prototype.add = function(item) {
|
|||
|
||||
var item = new Box(options);
|
||||
|
||||
this.append(item);
|
||||
this.items.push(item);
|
||||
this.append(item);
|
||||
|
||||
if (this.mouse) {
|
||||
item.on('click', function(data) {
|
||||
|
|
Loading…
Reference in New Issue