Fix resizing issue.
This commit is contained in:
+1
-1
@@ -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)}();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// Scrollbars / Frame resizes notifications.
|
// Scrollbars / Frame resizes notifications.
|
||||||
(function () {
|
(function () {
|
||||||
let height;
|
let height;
|
||||||
const heightLimit = window.outerHeight * 2;
|
const debug = false;
|
||||||
|
|
||||||
handleHeightChange(); // Initial frame's height setup.
|
handleHeightChange(); // Initial frame's height setup.
|
||||||
setupResizeListener(); // Listen to frame's height changes.
|
setupResizeListener(); // Listen to frame's height changes.
|
||||||
@@ -17,13 +17,22 @@
|
|||||||
|
|
||||||
function handleHeightChange(entries) {
|
function handleHeightChange(entries) {
|
||||||
const updatedHeight = getCurrentHeight();
|
const updatedHeight = getCurrentHeight();
|
||||||
if (height === updatedHeight || updatedHeight > heightLimit) {
|
|
||||||
|
if (debug) {
|
||||||
|
console.log('Height Updates', 'Old vs New: ' + height, updatedHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (height === updatedHeight) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RESIZE_CODE = 'resize:';
|
const RESIZE_CODE = 'resize:';
|
||||||
height = updatedHeight;
|
height = updatedHeight;
|
||||||
window.parent.postMessage(RESIZE_CODE + JSON.stringify({height}), '*');
|
window.parent.postMessage(RESIZE_CODE + JSON.stringify({height}), '*');
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
console.log('Resize message sent: ', height)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentHeight() {
|
function getCurrentHeight() {
|
||||||
|
|||||||
Reference in New Issue
Block a user