-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathReactivityExample.svelte
More file actions
71 lines (60 loc) · 1.51 KB
/
Copy pathReactivityExample.svelte
File metadata and controls
71 lines (60 loc) · 1.51 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<script lang="ts">
import { Splide, SplideSlide } from '@splidejs/svelte-splide';
import { generateSlides } from '../../utils';
const slides = generateSlides();
// Do not change readonly options later, such as `type`, `preloadPages`, etc.
const options = {
perPage: 2,
gap : 0,
height : '10rem',
rewind : true,
}
function onHeightChange( e: Event ): void {
options.height = `${ ( e.target as HTMLInputElement ).value || 5 }rem`;
}
</script>
<div class="wrapper">
<h2 id="reactivity-example-heading">Reactivity Example</h2>
<div style="margin-bottom: 1rem">
<label>
<span>gap:</span>
<input type="number" min="0" max="20" bind:value={ options.gap }/>
px
</label>
<label>
<span>perPage:</span>
<input type="number" min="1" max="5" bind:value={ options.perPage }/>
</label>
<label>
<span>height:</span>
<input
type="number"
min="5"
max="20"
value={ typeof options.height === 'string' ? parseInt( options.height ) : 5 }
on:input={ onHeightChange }
/>
rem
</label>
</div>
<Splide options={ options } aria-labelledby="reactivity-example-heading">
{ #each slides as slide }
<SplideSlide>
<img src={ slide.src } alt={ slide.alt }>
</SplideSlide>
{ /each }
</Splide>
</div>
<style>
label span {
margin-right: .5rem;
}
input {
height: 1.5rem;
width: 4rem;
font-family: inherit;
}
label {
margin-right: 1rem;
}
</style>