Skip to content

Commit

Permalink
Fix elem binding
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Dec 12, 2024
1 parent 5dc19a8 commit 7f8c9bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/embed/iframeSizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function informSize(
useScrollDimension = true,
updateStyleProps = false,
) {
console.log("informSize", element);
if (!element) return;

// Inform a parent window about an embed size
Expand Down Expand Up @@ -35,8 +36,9 @@ export function informSize(

export function setupResizeEvent(iframe) {
window.addEventListener("message", (event) => {
console.log("Message sent!", event.data);
if (event.source == iframe.contentWindow) {
console.log("Message received!", event.data);
console.log("iframe message received!", event.data);
const { width, height, updateStyleProps } = event.data;
if (width != null) {
iframe.width = width;
Expand Down
4 changes: 2 additions & 2 deletions src/routes/embed/documents/[id]/pages/[page]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
/>
</svelte:head>

<svelte:window on:keydown={onKeyup} />
<svelte:window on:keydown={onKeyup} on:load={() => informSize(elem)} />

<div class="dc-embed">
<div class="dc-embed" bind:this={elem}>
<div class="dc-page">
Page
{page}
Expand Down

0 comments on commit 7f8c9bc

Please sign in to comment.