Skip to content

Commit

Permalink
Fix remaining check warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanvugt committed Sep 2, 2023
1 parent c753626 commit 3be1fe0
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/routes/examples/iframes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,28 @@
src: `/?game=${gameId}&title=${gameTitle}&autoplay=true&fps=10`
},
{
id: "full-width",
title: "Full Width (100%)",
url: `https://play.battlesnake.com/game/${gameId}`,
width: "100%",
src: `/?game=${gameId}&title=${gameTitle}&autoplay=true&fps=10`
}
];
const isResized: string[] = [];
if (browser) {
window.addEventListener(
"message",
function (event) {
if (event.data.event == "TURN" && event.source.frameElement) {
const iframe = event.source.frameElement;
if (!isResized.includes(iframe.id)) {
setTimeout(() => {
const h = iframe.contentWindow.document.body.scrollHeight;
iframe.style.height = `${h}px`;
}, 100);
isResized.push(iframe.id);
function (message) {
if (message.source && message.data.event == "RESIZE") {
// We need to find which iframe sent the message
for (let i = 0; i < configs.length; i++) {
const iframeElement = this.document.getElementById(configs[i].id) as HTMLIFrameElement;
if (iframeElement.contentWindow == message.source) {
const height = iframeElement.contentWindow.document.body.scrollHeight;
setTimeout(() => {
iframeElement.style.height = `${height}px`;
}, 100);
}
}
}
},
Expand Down

0 comments on commit 3be1fe0

Please sign in to comment.