ui-layout-manager-dev 0.0.34-dev → 0.0.36-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Worker/LayoutWorker.js +6 -3
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/LayoutManager/Components/RootContainer/RootContainer.jsx +3 -1
- package/src/components/LayoutManager/Controller/LayoutController.js +23 -18
- package/src/components/LayoutManager/Controller/Worker/LayoutEditor.js +5 -2
- package/src/components/LayoutManager/Controller/Worker/LayoutWorker.js +1 -1
package/package.json
CHANGED
|
@@ -75,11 +75,12 @@ export class LayoutController {
|
|
|
75
75
|
this.containers[id] = containerApi;
|
|
76
76
|
this.containerRefs[id] = containerRef;
|
|
77
77
|
|
|
78
|
-
console.log(`Registered container with id: ${id} `);
|
|
78
|
+
// console.log(`Registered container with id: ${id} `);
|
|
79
79
|
|
|
80
80
|
if (this.registeredContainers === this.numberOfContainers && !this.layoutLoaded) {
|
|
81
|
-
console.log("All containers registered, layout is ready.");
|
|
82
|
-
this.sendToWorker(LAYOUT_WORKER_PROTOCOL.INITIALIZE_FLEXBOX
|
|
81
|
+
// console.log("All containers registered, layout is ready.");
|
|
82
|
+
this.sendToWorker(LAYOUT_WORKER_PROTOCOL.INITIALIZE_FLEXBOX,
|
|
83
|
+
{ sizes: this.getContainerSizes() });
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -91,26 +92,35 @@ export class LayoutController {
|
|
|
91
92
|
delete this.containers[id];
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
|
|
94
96
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
+
* Retuns the sizes of the containers.
|
|
98
|
+
* @return {Object} Size of containers.
|
|
97
99
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// console.log("Root container resized to:", width, height);
|
|
101
|
-
const sizes = {};
|
|
100
|
+
getContainerSizes() {
|
|
101
|
+
const containerSizes = {};
|
|
102
102
|
for (const id in this.containerRefs) {
|
|
103
103
|
if (this.containerRefs.hasOwnProperty(id)) {
|
|
104
104
|
const boundingRect = this.containerRefs[id].getBoundingClientRect();
|
|
105
|
-
|
|
105
|
+
containerSizes[id] = {
|
|
106
106
|
width: boundingRect.width,
|
|
107
107
|
height: boundingRect.height
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
+
return containerSizes;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* This function is called when the root container is resized.
|
|
116
|
+
* It will notify the worker to process the layout changes.
|
|
117
|
+
*/
|
|
118
|
+
handleRootResize() {
|
|
119
|
+
if (!this.layoutLoaded) return;
|
|
120
|
+
// console.log("Root container resized to:", width, height);
|
|
111
121
|
this.sendToWorker(
|
|
112
122
|
LAYOUT_WORKER_PROTOCOL.APPLY_SIZES,
|
|
113
|
-
{ sizes:
|
|
123
|
+
{ sizes: this.getContainerSizes() }
|
|
114
124
|
);
|
|
115
125
|
}
|
|
116
126
|
|
|
@@ -169,16 +179,11 @@ export class LayoutController {
|
|
|
169
179
|
break;
|
|
170
180
|
}
|
|
171
181
|
};
|
|
172
|
-
if (
|
|
182
|
+
if (isInitial) {
|
|
173
183
|
// After the initial transformations have been applied, we can hide
|
|
174
184
|
// the loading screen for the root container.
|
|
175
185
|
this.containers[this.ldf.layoutRoot].current.hideLoadingScreen();
|
|
176
|
-
|
|
177
|
-
if (isInitial) {
|
|
178
|
-
this.layoutLoaded = true;
|
|
179
|
-
// Call root resize to apply the layout rules after initial transformations
|
|
180
|
-
// are applied, this applies the layout rules to hide the containers.
|
|
181
|
-
this.handleRootResize();
|
|
186
|
+
console.log("Layout is ready, hiding loading screen.");
|
|
182
187
|
}
|
|
183
188
|
});
|
|
184
189
|
};
|
|
@@ -17,9 +17,12 @@ export class LayoutEditor {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Initializes flexbox layout by processing LDF file.
|
|
20
|
+
* @param {Object} sizes Initial sizes of the containers.
|
|
20
21
|
*/
|
|
21
|
-
initializeFlexBox() {
|
|
22
|
-
this.initializeNode(this.ldf.containers[this.ldf.layoutRoot]);
|
|
22
|
+
initializeFlexBox(sizes) {
|
|
23
|
+
this.initializeNode(this.ldf.containers[this.ldf.layoutRoot]);
|
|
24
|
+
this.sizes = sizes;
|
|
25
|
+
this.applyLayoutToNode(this.ldf.layoutRoot);
|
|
23
26
|
postMessage({
|
|
24
27
|
type: LAYOUT_WORKER_PROTOCOL.INITIALIZE_FLEXBOX,
|
|
25
28
|
data: this.transformations
|
|
@@ -17,7 +17,7 @@ self.onmessage = function (e) {
|
|
|
17
17
|
editor = new LayoutEditor(args.ldf);
|
|
18
18
|
break;
|
|
19
19
|
case LAYOUT_WORKER_PROTOCOL.INITIALIZE_FLEXBOX:
|
|
20
|
-
editor.initializeFlexBox();
|
|
20
|
+
editor.initializeFlexBox(args.sizes);
|
|
21
21
|
break;
|
|
22
22
|
case LAYOUT_WORKER_PROTOCOL.APPLY_SIZES:
|
|
23
23
|
editor.applySizes(args.sizes);
|