Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-infinite-scroll

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-infinite-scroll

Infinite Scroll Component to Svelte

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
decreased by-22.07%
Maintainers
1
Weekly downloads
 
Created
Source

Svelte Infinite Scroll

npm versionLicense: MITBuild StatusNetlify StatusLanguage grade: JavaScriptGitter

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.

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

  • Infinite scroll with requests | Link | Author
  • Infinite scroll reverse | Link | Author

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.

Keywords

FAQs

Package last updated on 06 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc