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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ark-floating-scroll

v1.2.1

Published

A high-performance virtualized list component for React that renders only visible items

Readme

ark-floating-scroll

A high-performance virtualized list component for React. Renders only the items visible in the viewport, dramatically reducing DOM nodes and improving performance for long lists.

Installation

npm install ark-floating-scroll

Peer dependencies: React ≥ 16.8.0

Quick Start

import { VirtualList } from "ark-floating-scroll";

const items = Array.from({ length: 10000 }, (_, i) => `Item ${i}`);

function App() {
  return (
    <VirtualList
      items={items}
      itemHeight={40}
      height={500}
      renderItem={(item, index) => (
        <div style={{ padding: "8px", borderBottom: "1px solid #eee" }}>
          {item}
        </div>
      )}
    />
  );
}

API

<VirtualList<T>>

| Prop | Type | Default | Description | |------|------|---------|-------------| | ref | Ref<VirtualListHandle> | — | Imperative handle with scrollToIndex | | items | T[] | required | Array of items to render | | itemHeight | number | auto | Fixed height of each item in pixels. If omitted, auto-calculated from first item. | | height | number | 400 | Height of the scrollable container | | width | number \| string | "100%" | Width of the scrollable container | | overscan | number | 5 | Extra items rendered above/below viewport | | renderItem | (item: T, index: number) => ReactNode | String(item) | Custom render function | | className | string | — | CSS class for the outer container | | style | CSSProperties | — | Inline styles for the outer container |

How It Works

  1. Scroll Detection — Listens to the container's scroll event, throttled via requestAnimationFrame for smooth 60fps updates.
  2. Range Calculation — Computes startIndex and endIndex from scrollTop / itemHeight, adding an overscan buffer.
  3. DOM Recycling — Only the visible slice of items is mounted in the DOM. Items outside the viewport are unmounted, keeping memory usage constant regardless of list size.

Scroll to Index

Use an imperative ref to programmatically scroll to any item:

import { useRef } from "react";
import { VirtualList, VirtualListHandle } from "ark-floating-scroll";

function App() {
  const listRef = useRef<VirtualListHandle>(null);

  return (
    <>
      <button onClick={() => listRef.current?.scrollToIndex(500, "smooth")}>
        Go to item 500
      </button>
      <VirtualList
        ref={listRef}
        items={items}
        itemHeight={40}
        height={500}
        renderItem={(item) => <div>{item}</div>}
      />
    </>
  );
}

scrollToIndex(index, behavior?) accepts an optional ScrollBehavior ("auto" or "smooth"). Defaults to "auto" (instant).

TypeScript

Full type definitions are included. The component is generic — your items type flows through to renderItem:

interface User {
  id: number;
  name: string;
}

<VirtualList<User>
  items={users}
  itemHeight={60}
  renderItem={(user) => <div>{user.name}</div>}
/>

Examples

The examples/ directory includes interactive demos (simple list, typed objects, dynamic add/remove).

npm run demo
# opens at http://localhost:5173

Open DevTools → Elements to confirm only ~20-30 DOM nodes exist regardless of list size.

License

MIT

ark-floating-scroll