File tree 1 file changed +24
-10
lines changed
1 file changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -27,18 +27,32 @@ yarn install && yarn start
27
27
``` js
28
28
< script>
29
29
import SvelteInfiniteScroll from " svelte-infinite-scroll" ;
30
+ import allCountries from " ./countries.js" ;
31
+
32
+ let page = 0 ;
33
+ let size = 20 ;
34
+ let countries = [];
35
+
36
+ $: countries = [
37
+ ... countries,
38
+ ... allCountries .splice (size * page, size * (page + 1 ) - 1 )
39
+ ];
30
40
< / script>
31
41
32
- < div
33
- style= " width:500px; height:500px;
34
- overflow-y:scroll;background:red;padding:20px" >
35
- < div style= " width:500px; height:900px; overflow-y:scroll; background:green" / >
36
- < SvelteInfiniteScroll
37
- threshold= {100 }
38
- on: loadMore= {() => {
39
- console .log (' load' );
40
- }} / >
41
- < / div>
42
+ < style>
43
+ ul {
44
+ width: 400px ;
45
+ max- height: 400px ;
46
+ overflow- x: scroll;
47
+ }
48
+ < / style>
49
+
50
+ < ul>
51
+ {#each countries as country}
52
+ < li> {country .name }< / li>
53
+ {/ each}
54
+ < SvelteInfiniteScroll threshold= {100 } on: loadMore= {() => page++ } / >
55
+ < / ul>
42
56
```
43
57
44
58
## Properties
You can’t perform that action at this time.
0 commit comments