@one-commerce/sdk-backoffice-vue3 1.12.0-alpha.0 → 1.12.1-alpha.0
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/lib/bundles/bundle.esm.js +37 -4
- package/lib/bundles/bundle.esm.js.map +1 -1
- package/lib/bundles/bundle.esm.min.js +1 -1
- package/lib/bundles/bundle.esm.min.js.map +1 -1
- package/lib/bundles/bundle.umd.js +37 -4
- package/lib/bundles/bundle.umd.js.map +1 -1
- package/lib/bundles/bundle.umd.min.js +1 -1
- package/lib/bundles/bundle.umd.min.js.map +1 -1
- package/package.json +3 -3
|
@@ -280,6 +280,8 @@ class Sdk extends Events {
|
|
|
280
280
|
|
|
281
281
|
_defineProperty(this, "autoheight", true);
|
|
282
282
|
|
|
283
|
+
_defineProperty(this, "heightMutationObserver", null);
|
|
284
|
+
|
|
283
285
|
_defineProperty(this, "origin", void 0);
|
|
284
286
|
|
|
285
287
|
_defineProperty(this, "isInitialized", false);
|
|
@@ -318,19 +320,50 @@ class Sdk extends Events {
|
|
|
318
320
|
this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, payload => {
|
|
319
321
|
if (this.autoheight) {
|
|
320
322
|
Sdk.log('Request for iframe height');
|
|
321
|
-
|
|
322
|
-
html = document.documentElement;
|
|
323
|
-
const height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
324
|
-
this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
|
|
323
|
+
this.sendFrameHeight();
|
|
325
324
|
}
|
|
326
325
|
});
|
|
327
326
|
this.channel.connect().then(() => {
|
|
328
327
|
Sdk.log('Connected with ONe SDK');
|
|
328
|
+
|
|
329
|
+
if (this.autoheight) {
|
|
330
|
+
this.initializeHeightObserver();
|
|
331
|
+
}
|
|
329
332
|
});
|
|
330
333
|
this.setupOptions(options);
|
|
331
334
|
Sdk.log('Initialized.');
|
|
332
335
|
}
|
|
333
336
|
|
|
337
|
+
sendFrameHeight() {
|
|
338
|
+
const body = document.body,
|
|
339
|
+
html = document.documentElement;
|
|
340
|
+
const height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
341
|
+
this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
initializeHeightObserver() {
|
|
345
|
+
if ("MutationObserver" in window) {
|
|
346
|
+
const onMutationObserved = () => {
|
|
347
|
+
this.sendFrameHeight();
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const target = document.querySelector('body'),
|
|
351
|
+
config = {
|
|
352
|
+
attributes: true,
|
|
353
|
+
attributeOldValue: false,
|
|
354
|
+
characterData: true,
|
|
355
|
+
characterDataOldValue: false,
|
|
356
|
+
childList: true,
|
|
357
|
+
subtree: true
|
|
358
|
+
};
|
|
359
|
+
this.heightMutationObserver = new MutationObserver(onMutationObserved);
|
|
360
|
+
Sdk.log('Create body MutationObserver');
|
|
361
|
+
this.heightMutationObserver.observe(target, config);
|
|
362
|
+
} else {
|
|
363
|
+
Sdk.warn('MutationObserver not available. Auto-height functionality disabled.');
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
334
367
|
setupOptions(options) {
|
|
335
368
|
if (options) {
|
|
336
369
|
if (typeof options.debug !== 'undefined') {
|