1.0.4 • Published 3 years ago

svelte-infinite-scrolling v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Svelte Infinite Scrolling

Infinite Scroll Component for Svelte.

Installation

npm i svelte-infinite-scrolling

Demo link

Examples

An example of how to use the library:

<script>
  import { onMount } from "svelte";
  import InfiniteScroll from "./InfiniteScroll.svelte";
  let posts = [];
  async function getPosts() {
    let res = await fetch("https://meme-api.herokuapp.com/gimme/10");
    let data = await res.json();
    posts = [...posts, ...data.memes];
    console.log(posts);
  }
  onMount(() => {
    getPosts();
  });
</script>

{#each posts as item}
  <h1 style="padding:1em">{item.title}</h1>
{/each}

<InfiniteScroll on:scroll={getPosts} />

Properties

Component props:

PropTypeDefaultDescription
on:scrollfunction0Function You Want To Run While Scrolling

Buy Me A Coffee