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

solidjs-virtualizedlist

v0.0.5

Published

1. Supports both horizontal and vertical rows. 2. Efficiently handles large datasets by rendering only the visible elements. 3. Provides a scrollTo function to programmatically scroll to a specific item.

Downloads

15

Readme

SolidJs Virtualized List

A lightweight, highly efficient virtualized list component for SolidJs that supports both horizontal and vertical rows, allowing you to efficiently render large datasets with ease.

Features

  1. Supports both horizontal and vertical rows.
  2. Efficiently handles large datasets by rendering only the visible elements.
  3. Provides a scrollTo function to programmatically scroll to a specific item.
npm i solidjs-virtualizedlist
Usage Example
import { createSignal } from "solid-js";
import { render } from "solid-js/web";
import { VirtualizedList } from "./virtualized-list.jsx";

const root = document.getElementById("root");

// Generate data for the list
let data = Array.from({ length: 1000000 }).map((v, i) => i + 1);

let scrollTo; // Declare a variable to hold the scrollTo function

const [scrollToKey, setScrollToKey] = createSignal(0); // Create a signal for the scroll target index

render(
  () => (
    <div>
      <VirtualizedList
        options={{
          containerSize: 500, // Height of the visible container
          dataLength: data.length, // Total length of the dataset
          cellHeightWidth: 20, // Height of each item in the list
          overscan: 10, // Number of extra items to render above and below the visible area
          direction: "y", // Direction of the list (vertical in this case)
          scrollTo: (cb) => (scrollTo = cb), // Callback to set the scrollTo function
          onScroll: (e) => {
            console.log(e); // Event handler for scroll events
          },
        }}
        parentContainerProps={{
          style: {
            width: "250px",
          },
        }}
        scrollContainerProps={{}}
      >
        {({ index }) => {
          return data[index] ? (
            <p style={{ height: "100%" }}>!{data[index]}</p> // Rendered item in the list
          ) : null;
        }}
      </VirtualizedList>
      <input
        type="number"
        placeholder="Index"
        onChange={(e) => setScrollToKey(() => e.target.value)}
      />
      <button onClick={() => scrollTo(+scrollToKey())}>Scroll</button> // Button
      to trigger scroll
    </div>
  ),
  root
);

| Property | Type | Description | | ---------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | | children | ({ index }: { index: number }) => JSX.Element | Function that takes an index and returns a React element to be rendered. | | options | VirtualizedListOptions | Configuration options for the virtualized list. | | parentContainerProps | React.DetailedHTMLProps<React.HTMLAttributes, HTMLDivElement> (optional) | HTML attributes for the parent container element. | | scrollContainerProps | React.DetailedHTMLProps<React.HTMLAttributes, HTMLDivElement> (optional) | HTML attributes for the scroll container element. |

VirtualizedListOptions

| Property | Type | Description | | ----------------- | -------------------------------------------------- | ----------------------------------------------------------------- | | containerSize | number | Height of the visible container. | | overscan | number (optional) | Number of extra items to render above and below the visible area. | | dataLength | number | Total length of the dataset. | | cellHeightWidth | number | Height or Width of each item in the list. | | direction | "x" | "y" (optional, default: "y") | Direction of the list (horizontal or vertical). | | scrollTo | (cb: (index: number) => void) => void (optional) | Callback to set the scrollTo function. | | debounce | number (optional) | Debounce value for scroll events (milliseconds). | | onScroll | (event: Event) => void (optional) | Event handler for scroll events. |