-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase-container-component.js
More file actions
44 lines (33 loc) · 1.02 KB
/
Copy pathbase-container-component.js
File metadata and controls
44 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const BaseLayoutComponent = require('./base-layout-component.js');
module.exports = class BaseContainerComponent extends BaseLayoutComponent {
constructor(properties) {
super(properties);
this.children = properties.children || [];
}
layoutComponent(document) {
for (let child of this.children) {
child.width = this.width - this.margin.horizontalTotal;
child.height = this.height - this.margin.verticalTotal;
child._originY = this._originY + this.y + this.margin.top;
child._originX = this._originX + this.x + this.margin.left;
child.layoutComponent(document);
}
}
afterGenerateComponent(document) {
if (!this._rendered) {
return;
}
super.afterGenerateComponent(document);
for (let child of this.children) {
child.afterGenerateComponent(document);
}
}
clone() {
const instance = super.clone();
instance.children = [];
for (let child of this.children) {
instance.children.push(child.clone());
}
return instance;
}
}