From 8eb7bea2e846fb9dab734908217406ec61157365 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Mon, 5 Dec 2022 14:26:01 +0200 Subject: [PATCH] Fix resizing issue. --- layouts/scripts/dist/frame-index.min.js | 2 +- layouts/scripts/frame/frame.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/layouts/scripts/dist/frame-index.min.js b/layouts/scripts/dist/frame-index.min.js index 719ec9d..83723ad 100644 --- a/layouts/scripts/dist/frame-index.min.js +++ b/layouts/scripts/dist/frame-index.min.js @@ -1 +1 @@ -!function(){let e;const t=2*window.outerHeight;function n(n){const o=document.querySelector("body > main").scrollHeight;if(e===o||o>t)return;e=o,window.parent.postMessage("resize:"+JSON.stringify({height:e}),"*")}n(),new ResizeObserver(n).observe(document.body)}(); +!function(){let e;function n(n){const t=document.querySelector("body > main").scrollHeight;if(e===t)return;e=t,window.parent.postMessage("resize:"+JSON.stringify({height:e}),"*")}n(),new ResizeObserver(n).observe(document.body)}(); diff --git a/layouts/scripts/frame/frame.js b/layouts/scripts/frame/frame.js index b20a63d..a616269 100644 --- a/layouts/scripts/frame/frame.js +++ b/layouts/scripts/frame/frame.js @@ -3,7 +3,7 @@ // Scrollbars / Frame resizes notifications. (function () { let height; - const heightLimit = window.outerHeight * 2; + const debug = false; handleHeightChange(); // Initial frame's height setup. setupResizeListener(); // Listen to frame's height changes. @@ -17,13 +17,22 @@ function handleHeightChange(entries) { const updatedHeight = getCurrentHeight(); - if (height === updatedHeight || updatedHeight > heightLimit) { + + if (debug) { + console.log('Height Updates', 'Old vs New: ' + height, updatedHeight); + } + + if (height === updatedHeight) { return; } const RESIZE_CODE = 'resize:'; height = updatedHeight; window.parent.postMessage(RESIZE_CODE + JSON.stringify({height}), '*'); + + if (debug) { + console.log('Resize message sent: ', height) + } } function getCurrentHeight() {