Skip to content

Commit 644f5e3

Browse files
Hide iframe until loaded to prevent flash of white when clicking bwd/fwd
1 parent 1df8dd0 commit 644f5e3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/routes/tutorial/[slug]/+page.svelte

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,18 @@
107107
}
108108
109109
onMount(() => {
110+
function on_iframe_load() {
111+
iframe.classList.add('loaded');
112+
}
110113
function destroy() {
114+
iframe.removeEventListener('load', on_iframe_load);
111115
if (adapter) {
112116
adapter.destroy();
113117
}
114118
}
115119
116120
document.addEventListener('pagehide', destroy);
121+
iframe.addEventListener('load', on_iframe_load);
117122
return destroy;
118123
});
119124
@@ -317,6 +322,7 @@
317322
// change the src without adding a history entry, which
318323
// would make back/forward traversal very annoying
319324
const parentNode = /** @type {HTMLElement} */ (iframe.parentNode);
325+
iframe.classList.remove('loaded');
320326
parentNode?.removeChild(iframe);
321327
iframe.src = src;
322328
parentNode?.appendChild(iframe);
@@ -497,6 +503,7 @@
497503
.content {
498504
display: flex;
499505
flex-direction: column;
506+
position: relative;
500507
min-height: 0;
501508
height: 100%;
502509
max-height: 100%;
@@ -539,10 +546,6 @@
539546
flex-direction: column;
540547
}
541548
542-
.content {
543-
position: relative;
544-
}
545-
546549
iframe {
547550
width: 100%;
548551
height: 100%;
@@ -553,6 +556,10 @@
553556
background: var(--sk-back-2);
554557
}
555558
559+
iframe:not(.loaded) {
560+
display: none;
561+
}
562+
556563
.editor-container {
557564
position: relative;
558565
background-color: var(--sk-back-3);

0 commit comments

Comments
 (0)