npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chrrubin/svelte-virtual-scroll-list

v1.1.3

Published

Svelte lib for virtualizing lists

Downloads

12

Readme

svelte-virtual-scroll-list

This is a fork of v1ack's svelte-virtual-scroll-list migrated to TypeScript to add support for TypeScript generics.

Usage

yarn add -D @chrrubin/svelte-virtual-scroll-list

<script lang="ts">
    import VirtualScroll from "@chrrubin/svelte-virtual-scroll-list"

    interface Item {
        id: number;
        text: string;
    }

    let items: Item[] = [{ id: 0, text: 'zero'}, { id: 1, text: 'one'}];
</script>

<VirtualScroll data={items} key="id" let:data>
  <div>{data.id}</div>
  <div>{data.text}<div>
</VirtualScroll>

Original README

npm

Svelte implementation of vue library vue-virtual-scroll-list

Virtualized scrolling for big lists


Support dynamic both-directional lists (see example)


Online demo: https://v1ack.github.io/svelte-virtual-scroll-list/

Simple example in Svelte REPL

Getting started

Installing from npm

npm i svelte-virtual-scroll-list -D

or

yarn add svelte-virtual-scroll-list -D

Using


<script>
    import VirtualScroll from "svelte-virtual-scroll-list"

    let items = [{id: 1, text: "one"}, ...]
</script>
<div class="vs">
    <VirtualScroll
            data={items}
            key="id"
            let:data
    >
        <div slot="header">
            This is a header set via slot
        </div>
        <div>
            {data.text}
        </div>
        <div slot="footer">
            This is a footer set via slot
        </div>
    </VirtualScroll>
</div>

More examples available in example folder

Comparing to other virtualizing components

| |svelte-virtual-scroll-list|svelte-virtual-list|svelte-tiny-virtual-list| |---|---|---|---| |handle dynamic size data|+|+|-| |scroll methods (to index)|+|-|+| |infinity scrolling|two-directional|-|one-directional with another lib| |initial scroll position|+|-|+| |sticky items|-|-|+| |top/bottom slots|+|-|+| |reached top/bottom events|+|-|-| |document as a list|+|-|-|

API

Props

|prop|type|default|description| |---|---|---|---| |data|object[]|null|Source for list| |key|string|id|Unique key for getting data from data| |keeps|number|30|Count of rendered items| |estimateSize|number|estimateSize|Estimate size of each item, needs for smooth scrollbar| |isHorizontal|boolean|false|Scroll direction| |pageMode|boolean|false|Let virtual list using global document to scroll through the list| |start|number|0|scroll position start index |offset|number|0|scroll position offset |topThreshold|number|0|The threshold to emit top event, attention to multiple calls. |bottomThreshold|number|0|The threshold to emit bottom event, attention to multiple calls.

Methods

Access to methods by component binding


<script>
    let vs
</script>

<VirtualScroll bind:this={vs}></VirtualScroll>
<button on:click={vs.scrollToBottom}>To bottom</button>

|method|arguments|description| |---|---|---| |scrollToBottom|none|Scroll list to bottom| |scrollToIndex|index: number|Set scroll position to a designated index| |scrollToOffset|offset: number|Set scroll position to a designated offset| |getSize|id: typeof props.key|Get the designated item size| |getSizes|none|Get the total number of stored (rendered) items| |getOffset|none|Get current scroll offset| |getClientSize|none|Get wrapper element client viewport size (width or height)| |getScrollSize|none|Get all scroll size (scrollHeight or scrollWidth)| |updatePageModeFront|none|When using page mode and virtual list root element offsetTop or offsetLeft change, you need call this method manually|

Events

|event|description| |---|---| |scroll|Scroll event| |top|Top of the list reached| |bottom|Bottom of the list reached|