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

@valaria/virtual-scroll

v0.0.1

Published

A direct-child virtual scrolling custom element with logical host DOM semantics

Readme

@valaria/virtual-scroll

<virtual-scroll> is a custom element that virtualizes only its authored direct children while preserving a logical host DOM view.

It is designed for:

  • variable-size children
  • normal browser layout for mounted children
  • external scroll roots, including window
  • direct-child host DOM compatibility
  • retention for focused or explicitly kept-alive children

Installation

pnpm add @valaria/virtual-scroll

Quick Start

Register the element once during app startup:

import { defineVirtualScrollElement } from '@valaria/virtual-scroll'

defineVirtualScrollElement()

Use it in markup:

<virtual-scroll axis="vertical" overscan="400" class="feed">
  <article>Row 1</article>
  <article>Row 2</article>
  <article>Row 3</article>
</virtual-scroll>

Author the host layout yourself:

.feed {
  display: block;
  height: 420px;
  overflow-y: auto;
  padding: 12px;
}

Public API

axis

Controls the active virtualization axis.

  • property: axis
  • attribute: axis
  • values: vertical, horizontal

overscan

Extra main-axis distance kept mounted outside the visible viewport.

  • property: overscan
  • attribute: overscan
  • unit: CSS pixels

scrollRoot

Overrides which element drives scroll position.

  • property: scrollRoot
  • attribute: scroll-root
  • attribute values: window or a CSS selector

Example:

const host = document.querySelector('virtual-scroll')!
host.scrollRoot = document.querySelector('#feed-scroller')!

keepAlive

Programmatic direct-child retention.

host.keepAlive = (child) => {
  return child instanceof Element && child.matches('.editor, .media-playing')
}

data-keep-alive

Declarative direct-child retention for a direct child.

<virtual-scroll axis="vertical" class="feed">
  <article data-keep-alive>Persistent row</article>
  <article>Virtualized row</article>
</virtual-scroll>

Host DOM Behavior

The host presents a logical direct-child view. These host APIs operate on authored direct children rather than runtime spacer DOM:

  • childNodes
  • children
  • firstChild
  • lastChild
  • firstElementChild
  • lastElementChild
  • childElementCount
  • appendChild
  • insertBefore
  • removeChild
  • replaceChild
  • append
  • prepend
  • replaceChildren
  • querySelector
  • querySelectorAll
  • innerHTML

Scroll Behavior

If the host is the real scroller, scrolling stays native. If an external scroll root is configured, the host proxies scrollTop, scrollLeft, scroll(), scrollTo(), and scrollBy() to the resolved scroll root.

Direct-child scrollIntoView() is virtualization-aware, including for parked direct children.

Framework Guidance

The host's direct-child boundary belongs to virtual-scroll.

Safer integrations:

  • React
  • Preact
  • Vue
  • Solid
  • Svelte

For Lit and similar marker-based runtimes, use stable wrapper elements as the direct children of the host and render framework content inside those wrappers.

See examples/ in the repository for end-to-end integration samples.