Fix overwrite of 'offset' value in reactive statement

pull/2903/head
Evan Moncuso 6 years ago
parent 42235cf64d
commit bd50b83b2d

@ -39,6 +39,10 @@
let isLoading = false; let isLoading = false;
const cache = {}; const cache = {};
function showExampleCodeOnChange() {
offset = 1;
}
$: title = title_by_slug[active_slug] || ''; $: title = title_by_slug[active_slug] || '';
$: first_slug = sections[0].examples[0].slug; $: first_slug = sections[0].examples[0].slug;
$: mobile = width < 768; // note: same as per media query below $: mobile = width < 768; // note: same as per media query below
@ -46,7 +50,7 @@
$: if (repl && active_slug) { $: if (repl && active_slug) {
if (active_slug in cache) { if (active_slug in cache) {
repl.set({ components: cache[active_slug] }); repl.set({ components: cache[active_slug] });
offset = 1; showExampleCodeOnChange();
} else { } else {
isLoading = true; isLoading = true;
fetch(`examples/${active_slug}.json`) fetch(`examples/${active_slug}.json`)
@ -59,7 +63,7 @@
.then(components => { .then(components => {
cache[active_slug] = components; cache[active_slug] = components;
repl.set({components}); repl.set({components});
offset = 1; showExampleCodeOnChange();
isLoading = false; isLoading = false;
}) })
.catch(() => { .catch(() => {

Loading…
Cancel
Save