Skip to content

Commit

Permalink
Added Feldspar resize listener
Browse files Browse the repository at this point in the history
  • Loading branch information
mellelieuwes committed Dec 8, 2023
1 parent e45458a commit 26684a8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/assets/js/feldspar_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export const FeldsparApp = {
this.onFrameLoaded();
});
iframe.setAttribute("src", this.el.dataset.src);

window.addEventListener("message", function(event) {
if (event.data.action === "resize") {
console.log("[FeldsparApp] resize event:", event.data.height)
iframe.setAttribute("style", `height:${event.data.height}px`);
}
})
},

getIframe() {
Expand All @@ -30,13 +37,6 @@ export const FeldsparApp = {
iframe.contentWindow.postMessage({ action, locale }, "*", [
this.channel.port2,
]);

const observer = new ResizeObserver(() => {
const height = iframe.contentWindow.document.body.scrollHeight;
iframe.setAttribute("style", `height:${height}px`);
});

observer.observe(iframe.contentWindow.document.body);
},

handleMessage(e) {
Expand Down

0 comments on commit 26684a8

Please sign in to comment.