2.0.1 • Published 2 years ago

svelte-infinite-scroll v2.0.1

Weekly downloads
207
License
MIT
Repository
github
Last release
2 years ago

Svelte Infinite Scroll

npm version License: MIT Build Status Netlify Status Language grade: JavaScript Gitter

Infinite Scroll Component to Svelte.

Installation

npm i svelte-infinite-scroll

// or

yarn add svelte-infinite-scroll

Note: to use this library in Sapper applications, install as devDependency. Take a look at this link.

Demo link

Local demo:

git clone https://github.com/andrelmlins/svelte-infinite-scroll.git
cd svelte-infinite-scroll
npm install && npm run dev

Examples

An example of how to use the library:

<script>
  import InfiniteScroll from "svelte-infinite-scroll";
  import allCountries from "./countries.js";

  let page = 0;
  let size = 20;
  let countries = [];

  $: countries = [
    ...countries,
    ...allCountries.splice(size * page, size * (page + 1) - 1)
  ];
</script>

<style>
  ul {
    width: 400px;
    max-height: 400px;
    overflow-x: scroll;
  }
</style>

<ul>
  {#each countries as country}
    <li>{country.name}</li>
  {/each}
  <InfiniteScroll threshold={100} on:loadMore={() => page++} />
</ul>

Another examples

Properties

Component props:

PropTypeDefaultDescription
thresholdnumber0Threshold to call loadMore
elementScrollnode-Element to bind scroll
windowboolfalseBind scroll in window
hasMorebooltrueTells you if there are more items to load
horizontalboolfalseChanging orientation
reverseboolfalseRevese scroll direction

Events

EventDescription
loadMoreTells you if there are more items to load

NPM statistics

Download stats for this NPM package.

NPM

License

Svelte Infinite Scroll is open source software licensed as MIT.

2.0.1

2 years ago

2.0.0

3 years ago

1.5.2

3 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.2.0-alpha.4

4 years ago

1.2.0-alpha.2

4 years ago

1.2.0-alpha.3

4 years ago

1.2.0-alpha.1

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago