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

vue-smart-scroll

v0.1.5

Published

Modular Vue 3 infinite scroll and pull-to-refresh components with composables — tree-shakeable, SSR-safe, style-agnostic.

Readme

vue-smart-scroll

Production-oriented Vue 3 infinite scroll and pull-to-refresh primitives: three tree-shakeable components plus headless composables. Written in TypeScript, built with Vite, no UI framework, SSR-safe (browser APIs run after mount), and style-agnostic aside from small scoped defaults you can override.

Installation

npm install vue-smart-scroll

Peer dependency: Vue ^3.5 (uses useId for SVG defs).

Styles

Default spinner / layout helpers ship as a small CSS file:

import 'vue-smart-scroll/style.css'

You can skip this import and style slots yourself.

Quick start

<script setup lang="ts">
import { ref } from 'vue'
import { SmartScrollContainer } from 'vue-smart-scroll'
import 'vue-smart-scroll/style.css'

const items = ref<number[]>([1, 2, 3])
const hasMore = ref(true)

async function loadMore() {
  await new Promise((r) => setTimeout(r, 400))
  const n = items.value.length
  items.value.push(n + 1, n + 2, n + 3)
  if (items.value.length > 30) hasMore.value = false
}

async function onRefresh() {
  await new Promise((r) => setTimeout(r, 500))
  items.value = [1, 2, 3]
  hasMore.value = true
}
</script>

<template>
  <SmartScrollContainer
    style="height: 70vh"
    :pull-to-refresh="true"
    :load-more="loadMore"
    :on-refresh="onRefresh"
    :has-more="hasMore"
  >
    <div v-for="i in items" :key="i" style="padding: 12px; border-bottom: 1px solid #eee">
      Row {{ i }}
    </div>
  </SmartScrollContainer>
</template>

Run the bundled demo:

npm install
npm run dev

Components

SmartInfiniteScroll

IntersectionObserver-driven loader with slots for loader, error (with retry + error), and end.

| Prop | Type | Default | Description | |------|------|---------|-------------| | loadMore | () => Promise<void> | — | Fetches the next page. | | hasMore | boolean | — | false when the server has no next page. | | threshold | number \| number[] | 0 | IntersectionObserver threshold. | | disabled | boolean | false | Disables loads. | | immediate | boolean | false | Runs loadMore once on mount. | | autoLoad | boolean | true | false = no observer; call triggerLoadMore() (exposed) yourself. | | root | Element \| null | — | Scroll root; null = viewport. If omitted inside SmartPullToRefresh, the internal scroll element is injected. | | rootMargin | string | '0px' | Passed to IntersectionObserver. |

Events: load, error (payload: unknown), end.

Expose: triggerLoadMore(), retry().

SmartPullToRefresh

Touch pull with rubber-band resistance, optional window mode, and an indicator slot.

| Prop | Type | Default | Description | |------|------|---------|-------------| | onRefresh | () => Promise<void> | — | Refresh handler. | | threshold | number | 42 | Pull distance (px) to commit refresh. | | maxPullDistance | number | 90 | Visual cap (px). | | disabled | boolean | false | Disables gestures. | | useWindowScroll | boolean | false | Uses window scroll + document.documentElement for touch. |

Events: refresh (when a refresh starts), pulling (distance), release ({ distance, willRefresh }).

Expose: scrollEl (internal scroller ref when not using window mode).

SmartScrollContainer

Composes the two features: toggles infinite, pullToRefresh, and useWindowScroll, forwards slots (loader, error, end, indicator).

Composables

Use independently for virtualized lists or custom markup.

  • useInfiniteScroll(options) — sentinel ref, phases (idle | loading | error | complete), triggerLoadMore, retry, IntersectionObserver wiring, immediate / autoLoad.
  • usePullToRefresh(options)pullDistance, isRefreshing, attach() / detach() (binds passive touchstart and non-passive touchmove when pulling).
  • useScrollPosition({ target, throttle }) — reactive scrollTop / scrollLeft with passive scroll listeners and optional rAF coalescing.

Injection

SmartPullToRefresh provides VSS_SCROLL_ROOT so nested SmartInfiniteScroll can omit root and still observe against the correct scroller.

Performance notes

  • touchstart uses passive listeners; touchmove is non-passive only on the bound element when overscrolling from the top (needed for preventDefault).
  • Pull distance notifications are coalesced with requestAnimationFrame.
  • Observers and DOM listeners are removed on unmount; guards avoid running in SSR.

Package exports

Named exports from vue-smart-scroll: components, composables, types (LoadMoreFn, RefreshFn, InfiniteScrollPhase, …), helpers (readScrollTop, rubberBandResistance, …), and VSS_SCROLL_ROOT.