diff --git a/modules/Constants.js b/modules/Constants.js index 81ec634..8585569 100644 --- a/modules/Constants.js +++ b/modules/Constants.js @@ -104,7 +104,7 @@ var healthCheckCounterEnum = Object.freeze({ errorMessage: "cly_hc_error_message", }); -var SDK_VERSION = "24.11.0"; +var SDK_VERSION = "24.11.2"; var SDK_NAME = "javascript_native_web"; // Using this on document.referrer would return an array with 17 elements in it. The 12th element (array[11]) would be the path we are looking for. Others would be things like password and such (use https://regex101.com/ to check more) diff --git a/modules/CountlyClass.js b/modules/CountlyClass.js index 59db5f6..864d6b8 100644 --- a/modules/CountlyClass.js +++ b/modules/CountlyClass.js @@ -3724,6 +3724,21 @@ constructor(ob) { window.addEventListener('message', (event) => { this.#interpretContentMessage(event); }); + let resizeTimeout; + window.addEventListener('resize', () => { + clearTimeout(resizeTimeout); + resizeTimeout = setTimeout(() => { + const width = window.innerWidth; + const height = window.innerHeight; + const iframe = document.getElementById(this.#contentIframeID); + iframe.contentWindow.postMessage( + { type: 'resize', width: width, height: height }, + '*' + ); + }, 200); + }); + + }, true); }; @@ -3759,7 +3774,7 @@ constructor(ob) { this.#log(logLevelEnums.ERROR, "sendContentRequest, Received message from invalid origin"); return; } - const {close, link, event} = messageEvent.data; + const {close, link, event, resize_me} = messageEvent.data; if (event) { this.#log(logLevelEnums.DEBUG, "sendContentRequest, Received event: [" + event + "]"); @@ -3790,6 +3805,20 @@ constructor(ob) { this.#log(logLevelEnums.DEBUG, `sendContentRequest, Opened link in new tab: [${link}]`); } + if (resize_me) { + this.#log(logLevelEnums.DEBUG, "sendContentRequest, Resizing iframe"); + const resInfo = this.#getResolution(true); + var dimensionToUse = resize_me.p; + if (resInfo.width >= resInfo.height) { + dimensionToUse = resize_me.l; + }; + const iframe = document.getElementById(this.#contentIframeID); + iframe.style.left = dimensionToUse.x + "px"; + iframe.style.top = dimensionToUse.y + "px"; + iframe.style.width = dimensionToUse.w + "px"; + iframe.style.height = dimensionToUse.h + "px"; + } + if (close === 1) { this.#closeContentFrame(); }