mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-11 12:41:43 +08:00
31 lines
662 B
JavaScript
31 lines
662 B
JavaScript
|
|
import BasicWidget from "./basic_widget.js";
|
||
|
|
|
||
|
|
export default class AbstractContainer extends BasicWidget {
|
||
|
|
constructor() {
|
||
|
|
super();
|
||
|
|
|
||
|
|
this.children = [];
|
||
|
|
|
||
|
|
this.positionCounter = 10;
|
||
|
|
}
|
||
|
|
|
||
|
|
child(...components) {
|
||
|
|
if (!components) {
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
super.child(...components);
|
||
|
|
|
||
|
|
for (const component of components) {
|
||
|
|
if (!component.position) {
|
||
|
|
component.position = this.positionCounter;
|
||
|
|
this.positionCounter += 10;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.children.sort((a, b) => a.position - b.position < 0 ? -1 : 1);
|
||
|
|
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
}
|