Skip to content

LukasHechenberger/svelte-infinite-scroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Svelte Infinite Scroll

npm versionLicense: MITBuild StatusDependenciesNetlify StatusLanguage grade: JavaScript

Infinite Scroll Component to Svelte

Installation

npm i svelte-infinite-scroll
// OR
yarn add svelte-infinite-scroll

Demo Link

Local demo:

git clone https://github.com/andrelmlins/svelte-infinite-scroll.git
cd svelte-infinite-scroll
yarn && yarn start

Examples

<script>
  import SvelteInfiniteScroll 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}
  <SvelteInfiniteScroll threshold={100} on:loadMore={() => page++} />
</ul>

Properties

Component props:

Prop Type Description
threshold number Threshold to call loadMore
elementScroll node Element to bind scroll
hasMore bool Tells you if there are more items to load
loadMore func Call with offset

NPM Statistics

Download stats for this NPM package

NPM

License

Svelte Infinite Scroll is open source software licensed as MIT.

About

Infinite Scroll Component to Svelte

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 69.1%
  • HTML 30.1%
  • CSS 0.8%