Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/routes/tutorial/[slug]/Output.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
function set_iframe_src(src) {
if (!iframe) return; // HMR

// To prevent iframe flickering.
// Set to `visible` by calling `set_iframe_visible` function
// from iframe on:load or setTimeout
iframe.style.visibility = 'hidden';
setTimeout(set_iframe_visible, 1000);

// removing the iframe from the document allows us to
// change the src without adding a history entry, which
// would make back/forward traversal very annoying
Expand All @@ -82,6 +88,12 @@
iframe.src = src;
parentNode?.appendChild(iframe);
}

function set_iframe_visible() {
if (iframe.style.visibility === 'hidden') {
iframe.style.visibility = 'visible';
}
}
</script>

<svelte:window on:message={handle_message} />
Expand All @@ -105,7 +117,7 @@

<div class="content">
{#if browser}
<iframe bind:this={iframe} title="Output" />
<iframe bind:this={iframe} title="Output" on:load={set_iframe_visible} />
{/if}

{#if paused || loading || $error}
Expand Down