You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
600 B
21 lines
600 B
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');
|
|
}
|
|
|