Skip to content

Commit

Permalink
Merge pull request #2903 from evanmoncuso/issue_2898
Browse files Browse the repository at this point in the history
Issue #2898 -- Fix overwrite of 'offset' value in reactive statement
  • Loading branch information
Rich-Harris authored May 29, 2019
2 parents 42235cf + bd50b83 commit 7105788
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions site/src/routes/examples/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@
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
$: replOrientation = (mobile || width > 1080) ? 'columns' : 'rows';
$: 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`)
Expand All @@ -59,7 +63,7 @@
.then(components => {
cache[active_slug] = components;
repl.set({components});
offset = 1;
showExampleCodeOnChange();
isLoading = false;
})
.catch(() => {
Expand Down

0 comments on commit 7105788

Please sign in to comment.