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 🙏

© 2025 – Pkg Stats / Ryan Hefner

svelte-magic-scroller

v0.1.17

Published

[![NPM Version](https://img.shields.io/npm/v/svelte-magic-scroller?style=flat)](https://www.npmjs.com/package/svelte-magic-scroller) [![NPM Downloads](https://img.shields.io/npm/dm/svelte-magic-scroller)](https://www.npmjs.com/package/svelte-magic-scrolle

Readme

Svelte Magic Scroller

NPM Version NPM Downloads NPM Unpacked Size

It's not real - it's just magic

This package is a virtualized infinite scroller which enables the scrolling of unlimited items of unknown dimensions. Only items in the vicinity of the current viewport are rendered.

Works best for super large lists like an activity feed or photo gallery

Demo

Features

  • No restrictions to dimensions of virtualized lists (exceeds the 33554428px on Chrome/Safari, 33554400px on Firefox browser dimension limit)
  • Lazy loading
  • Low memory footprint
  • Configurable scroll speed
  • Fixed/Dynamic item sizes
  • Middle mouse button drag scroll support
  • Made for Svelte 5
  • No dependencies

Install

npm install svelte-magic-scroller

yarn i svelte-magic-scroller

pnpm i svelte-magic-scroller

How to use

Minimal example

<script>
  const INITIAL_LENGTH = 5000000000000;
  let length = $state(INITIAL_LENGTH); // list size
  let index = $state(0); // first full item visible in viewport
  let offset = $state(0); // y offset from top
  let ref = $state();
</script>

{#snippet item(i)}
  <Item index={i} {length} />
{/snippet}

<MagicScroller
  bind:this={ref}
  bind:index
  bind:offset
  itemStyle={`display: flex; justify-content: center;`}
  width="100%"
  height="100%"
  {length}
  {item}
/>

Configuration

  • {number} buffer - Number of items to buffer above and below visible area

Friction coefficients for different scroll speeds

  • {number} friction.fast - Friction for fast swipes (0.99)
  • {number} friction.medium - Friction for medium swipes (0.98)
  • {number} friction.slow - Friction for slow swipes (0.95)

Velocity thresholds

  • {number} velocity.fast - Threshold for fast swipes (30)
  • {number} velocity.medium - Threshold for medium swipes (15)

Bounce effect configuration

  • {number} bounce.tension - Bounce resistance (0.3)
  • {number} bounce.returnSpeed - Speed of return animation (0.15)
config = {
  buffer: 15,
  friction: {
    fast: 0.99,
    medium: 0.98,
    slow: 0.95
  },
  velocity: {
    fast: 30,
    medium: 15
  },
  bounce: {
    tension: 0.3,
    returnSpeed: 0.15
  }
};

You can pull from the base configuration if you only want to change a few values to keep the rest on the defaults.

config = {
  ...baseScrollerConfig,
  buffer: 50
};

Go to

You can use goto(index) to jump to any place in the list (e.g. ref?.goto(256000)). If you would like to offset the location, you can add to the optional parameters (e.g. ref?.goto(256000, { offset: 64})).

The goto function does not support smooth scrolling when performing large list jumps, unless the target item is already in the buffer.

Scroll bar

It is recommended to implement your own scroll bar to match your UX requirements. This is due to handling experience as the list size increase - the implementation of a scrollbar with 10,000 will likely need to differ significantly to another list with 1,000,000+ items.

A basic scrollbar example can be found in the repo here

Quirks

  • while index and offset are bindable and can be set to move to any location on the list, it is recommended to use goto() to set the correct positions at the start/end of the list
  • No support for iOS Safari status bar go to top tap action