Fix scrolling issues & swiperjs conflicts.
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
export function setupFrameResizeListener() {
|
||||
const previewFrame = getPreviewFrame();
|
||||
|
||||
window.addEventListener('message', function (e) {
|
||||
const RESIZE_CODE = 'resize:';
|
||||
if (typeof e.data !== 'string' || !e.data.startsWith(RESIZE_CODE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const data = JSON.parse(e.data.substring(RESIZE_CODE.length))
|
||||
let height = Number.parseInt(data.height)
|
||||
if (height > 20000) {
|
||||
height = 20000; // Limit max height.
|
||||
}
|
||||
previewFrame.style.height = height + 'px'
|
||||
});
|
||||
}
|
||||
|
||||
export function getPreviewFrame() {
|
||||
return document.getElementById('preview_frame');
|
||||
}
|
||||
@@ -15,46 +15,6 @@ function initBlock(blockName = '', selector = '', cb) {
|
||||
reload();
|
||||
}
|
||||
|
||||
// Scrollbars / Frame resizes notifications.
|
||||
(function () {
|
||||
let height;
|
||||
const debug = false;
|
||||
|
||||
handleHeightChange(); // Initial frame's height setup.
|
||||
setupResizeListener(); // Listen to frame's height changes.
|
||||
|
||||
///
|
||||
|
||||
function setupResizeListener() {
|
||||
const resizeObserver = new ResizeObserver(handleHeightChange);
|
||||
resizeObserver.observe(document.body);
|
||||
}
|
||||
|
||||
function handleHeightChange() {
|
||||
const updatedHeight = getCurrentHeight();
|
||||
|
||||
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() {
|
||||
return document.querySelector('#hbs-container').scrollHeight;
|
||||
}
|
||||
})();
|
||||
|
||||
// Data Updates Listeners.
|
||||
(function () {
|
||||
loadDataOptions();
|
||||
|
||||
Reference in New Issue
Block a user