From 841176451a302cc26dc6bda88eb49689b272c556 Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:27:34 +0900 Subject: [PATCH] resize event --- modules/Constants.js | 2 +- modules/CountlyClass.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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..c7741d9 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); };