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

sigma-scrollkit

v1.0.16

Published

Advanced virtual scrolling module for Vue 3.

Downloads

12

Readme

Sigma ScrollKit

Advanced virtual scrolling module for Vue 3.

Originally created for the parent project: Sigma File Manager v2.

Features

  • Supports complex list view.
  • Supports complex grid view.
  • Programmatic control.
  • Grid view generates automatically based on the specified min column width, and adapts to the viewport / window size.
  • Supports arbitrary dynamic item height, row and column gaps.
  • Allows to build complex virtual scrollers programmatically with spacers, dividers and item groups of different sizes.
  • Supports custom scrollbars.
  • Emits many useful events, including scroll statuses like is-scrolling, bottom-reached, etc.
  • Scrollbar doesn't jitter when scrolling because the item height is known in advance.

Supporters

Consider supporting my work

Installation

npm install sigma-scrollkit

Usage

The module renders a list of virtual rows (virtual entries) in both the list and grid views. The difference is that in list view the column count is always 1.

Demo playground

Interface

interface VirtualEntryItem {
  [key: string]: unknown;
}

export interface VirtualEntry {
  id: number | string;
  height: number;
  rowGap: number;
  columnGap: number;
  items: VirtualEntryItem[];
  [key: string]: unknown;
}

interface Props {
  virtualEntries: VirtualEntry[];
  scrollerId: string;
  layoutType: "list" | "grid";
  minColumnWidth?: number;
  bufferItemCount?: number;
  calcExtraInfo?: boolean;
  topOffsetTrigger?: number;
  bottomOffsetTrigger?: number;
}

Template structure

<script setup>
import {VirtualScroller, VirtualScrollerRow} from 'sigma-scrollkit'
import type {VirtualEntry} from 'sigma-scrollkit/types/shared';

// ...
</script>

<template>
  <VirtualScroller
    ref="virtualGridRef"
    layout-type="grid"
    :scroller-id="0"
    :virtual-entries="formattedDirEntries"
    :min-column-width="minColumnWidth"
    @viewport-mounted="onViewportMounted"
    @top-reached="onTopReached"
    @bottom-reached="onBottomReached"
    @is-scrollable="onIsScrollable"
  >
    <template #viewport="{ renderedItems, scrolling, maxColumns }">
      <VirtualScrollerRow
        v-for="virtualEntry in renderedItems"
        :key="virtualEntry.id"
        :virtual-entry="virtualEntry"
        :max-columns="maxColumns"
      >
        <Component
          :is="componentReference[virtualEntry.component]"
          v-for="(item, index) in virtualEntry.items"
          :key="index"
          :height="virtualEntry.height"
          :hover-enabled="!scrolling"
          :dir-entry="item"
          layout-type="grid"
          v-bind="'props' in item && item.props"
          :style="`height: ${virtualEntry.height}px`"
        />
      </VirtualScrollerRow>
    </template>
  </VirtualScroller>
</template>

Components

The module exports 2 components:

  • VirtualScroller - main container component, calculates all the logic and renders virtual list / grid.
  • VirtualScrollerRow - component needed to wrap each row in the virtual container.

API

VirtualScroller props:

virtualEntries

  • Required: true
  • Type: VirtualEntry[]

scrollerId

  • Required: true
  • Type: string

layoutType

  • Required: true
  • Type: 'list' | 'grid'

minColumnWidth

  • Required: false
  • Type: number

bufferItemCount

  • Required: false
  • Type: number

calcExtraInfo

  • Required: false
  • Type: boolean
  • Description: if true, extra data properties will be calculated and emited in the scroll event:
    • scrollSpeed: current scroll speed

VirtualScroller events:

viewport-mounted

  • Type: {viewport: Ref<HTMLElement | null>; selector: string}

scroll

  • Type: ScrollEmitValue

scrolling

  • Type: boolean

is-scrollable

  • Type: boolean

top-reached

  • Type: boolean

bottom-reached

  • Type: boolean

VirtualScrollerRow props:

virtualEntry

  • Required: true
  • Type: VirtualEntry

maxColumns

  • Required: true
  • Type: number