Skip to content

Commit

Permalink
feat: add reload button
Browse files Browse the repository at this point in the history
  • Loading branch information
istudyatuni committed May 13, 2022
1 parent 5c71135 commit 14cb458
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/components/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
setHash,
resetHash,
} from 'src/stores/settings'
import { redraw as redrawStore } from 'src/stores/refresh'
import {
redraw as redrawStore,
reload as reloadStore,
} from 'src/stores/refresh'
import { drawMandelbrot } from 'src/utils/draw'
import { MAPS } from 'src/utils/maps'
Expand Down Expand Up @@ -37,8 +40,12 @@
should_redraw()
}
function should_redraw() {
if ($reloadStore) return
redrawStore.set(true)
}
function should_reload() {
reloadStore.set(true)
}
function reset() {
drawStore.set('lx', -3)
drawStore.set('rx', 1)
Expand All @@ -54,7 +61,14 @@
{#if $settings.show_settings}
<div class="flex justify-between mb-3">
<Button on:click={toggleShow} class="mr-2">Collapse</Button>
<Button on:click={drawMandelbrot} disabled={!$redrawStore}>Redraw</Button>
<span>
<Button on:click={() => location.reload()} disabled={!$reloadStore}>
Reload
</Button>
<Button on:click={drawMandelbrot} disabled={!$redrawStore}>
Redraw
</Button>
</span>
</div>

<div class="mb-2">
Expand Down Expand Up @@ -100,7 +114,7 @@
<select
class="p-1 rounded capitalize"
bind:value={$settings.palette}
on:change={should_redraw}>
on:change={should_reload}>
{#each Object.entries(MAPS) as [key, map]}
<option value={key}>{map.name}</option>
{/each}
Expand Down

0 comments on commit 14cb458

Please sign in to comment.