Browse Source

Fix resizing issue.

pull/6/head
Roman Axelrod 3 years ago
parent
commit
8eb7bea2e8
  1. 2
      layouts/scripts/dist/frame-index.min.js
  2. 13
      layouts/scripts/frame/frame.js

2
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)}();

13
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() {

Loading…
Cancel
Save