Merge pull request #2903 from evanmoncuso/issue_2898

Issue #2898 -- Fix overwrite of 'offset' value in reactive statement
pull/2907/head
Rich Harris 5 years ago committed by GitHub
commit 7105788214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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