Skip to content

Commit

Permalink
Add debug logging to embed scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Dec 12, 2024
1 parent 36fa944 commit 5dc19a8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/embed/iframeSizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ export function informSize(

// Inform a parent window about an embed size
const update = () => {
const width = Math.max(
useScrollDimension ? element.scrollWidth : 0,
element.offsetWidth,
);
const height = Math.max(
useScrollDimension ? element.scrollHeight : 0,
element.offsetHeight,
);
console.log(`Posting size message: ${width}x${height}`);
window.parent.postMessage(
{
width: Math.max(
useScrollDimension ? element.scrollWidth : 0,
element.offsetWidth,
),
height: Math.max(
useScrollDimension ? element.scrollHeight : 0,
element.offsetHeight,
),
width,
height,
updateStyleProps,
},
"*",
Expand All @@ -33,6 +36,7 @@ export function informSize(
export function setupResizeEvent(iframe) {
window.addEventListener("message", (event) => {
if (event.source == iframe.contentWindow) {
console.log("Message received!", event.data);
const { width, height, updateStyleProps } = event.data;
if (width != null) {
iframe.width = width;
Expand Down

0 comments on commit 5dc19a8

Please sign in to comment.