-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathControls.svelte
52 lines (48 loc) · 1.03 KB
/
Controls.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script>
export let currentWidth
export let bar
let width = 10
const progressStart = () => {
bar.start()
}
const progressComplete = () => {
bar.complete()
}
const progressStop = () => {
bar.stop()
}
const progressIncrement = (size) => {
const max = bar.getState().maximum
let width = bar.getState().width + size
if (width > max) {
width = max
}
bar.$$set({ width })
}
const progressContinue = () => {
bar.animate()
}
const setWidthRatio = (width) => {
bar.setWidthRatio(width / 100)
}
</script>
<button on:click={progressStart}>
Restart
</button>
<button on:click={progressComplete}>
Complete
</button>
<button on:click={progressStop}>
Stop Auto-Increment
</button>
<button on:click={() => progressIncrement(0.2)}>
Increment by 20%
</button>
<button on:click={progressContinue}>
Continue Auto-Increment
</button>
<button class="inline" on:click={() => setWidthRatio(width)}>
Set Width
(Currently {Math.round(currentWidth * 10000) / 100})
</button>
<input class="inline" type="number" bind:value={width}>