From bd50b83b2dc95c3bee723ed50a13f406dcfafd67 Mon Sep 17 00:00:00 2001 From: Evan Moncuso Date: Wed, 29 May 2019 15:15:01 -0400 Subject: [PATCH] Fix overwrite of 'offset' value in reactive statement --- site/src/routes/examples/index.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/site/src/routes/examples/index.svelte b/site/src/routes/examples/index.svelte index b21d0c773d..9fd783f950 100644 --- a/site/src/routes/examples/index.svelte +++ b/site/src/routes/examples/index.svelte @@ -39,6 +39,10 @@ let isLoading = false; const cache = {}; + function showExampleCodeOnChange() { + offset = 1; + } + $: title = title_by_slug[active_slug] || ''; $: first_slug = sections[0].examples[0].slug; $: mobile = width < 768; // note: same as per media query below @@ -46,7 +50,7 @@ $: if (repl && active_slug) { if (active_slug in cache) { repl.set({ components: cache[active_slug] }); - offset = 1; + showExampleCodeOnChange(); } else { isLoading = true; fetch(`examples/${active_slug}.json`) @@ -59,7 +63,7 @@ .then(components => { cache[active_slug] = components; repl.set({components}); - offset = 1; + showExampleCodeOnChange(); isLoading = false; }) .catch(() => {