Skip to content

Commit fd4f21c

Browse files
committed
Change example in README
1 parent ebd3419 commit fd4f21c

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

README.md

+24-10
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,32 @@ yarn install && yarn start
2727
```js
2828
<script>
2929
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+
];
3040
</script>
3141

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>
4256
```
4357

4458
## Properties

0 commit comments

Comments
 (0)