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

@kstackz/use-gesture

v0.0.0

Published

Touch gestures for React: every finger of a touch as motion values, in nested zones that own touch.

Readme

@kstackz/use-gesture

Touch gestures for React: every finger of a touch as motion values, in nested zones that own touch.

Big picture

A web app that wants a sidebar you swipe open, a list you pull to refresh, or a row you swipe for actions has to take touches away from the browser without breaking scrolling, clicks, or the other gestures on the same screen. This package does that part once. A GestureProvider follows every finger, and GestureZones mark the areas where the app owns touch. useGesture hands over each finger of a touch, including lifted ones, as motion values.

The core never decides what a touch means. Two layers above it do: Recognizers such as useSwipe read one generic meaning with live feedback, and Patterns such as useSidebar and usePullToRefresh are whole touch behaviours an app uses as they are. Each layer depends only on the one below. The Patterns come from the package root with the provider and zone; Recognizers and Core have their own entry points. It started as ui-toolkit's gestures block; ui-toolkit's Native block builds its app-like navigation on it.

The language is in CONTEXT.md, and the decisions that shaped it are in docs/adr/. They are numbered from 0002 because 0001 is the Native block's and stayed in ui-toolkit. The agent guide is SKILL.md.

Install

pnpm add @kstackz/use-gesture motion react react-dom
  • motion: every finger's position is a Motion value, so movement never re-renders React, and velocity comes with it.
  • react, react-dom: the provider, zones and hook are React components and hooks.

Exports

@kstackz/use-gesture

| Export | What it does | | ------------------ | ------------------------------------------------------------------------------------------- | | GestureProvider | Follows every finger for the zones inside it and runs one Gesture at a time. | | GestureZone | A div that marks where the app owns touch; zones nest, and trapped stops the walk. | | useSidebar | A sidebar that follows a Swipe from anywhere, or only its edge, and settles open or closed. | | usePullToRefresh | Pull to refresh: a resisted Swipe down that refreshes when released armed. |

@kstackz/use-gesture/recognizers

| Export | What it does | | ---------- | ----------------------------------------------------------------------------------------------------- | | useSwipe | The Swipe Recognizer: fingers moving one way, with live offset, velocity and whether it would Commit. |

@kstackz/use-gesture/core

| Export | What it does | | ------------ | -------------------------------------------------------------------------- | | useGesture | Reads the Gestures its nearest zone hears, as each finger's motion values. |

Usage

Swipe a row open inside a list

The whole screen is a zone, and each row is a zone inside it. A row is trapped while its actions are open, so the screen's own gestures never hear touches that start on it.

import { GestureProvider, GestureZone } from '@kstackz/use-gesture';
import { useGesture } from '@kstackz/use-gesture/core';

<GestureProvider>
  <GestureZone className="fixed inset-0">
    {rows.map((row) => (
      <GestureZone key={row.id} trapped={row.actionsOpen}>
        <RowActions row={row} />
      </GestureZone>
    ))}
  </GestureZone>
</GestureProvider>;

function RowActions({ row }) {
  useGesture({
    onEnd: (pointers, { interrupted, preventClick }) => {
      const [first] = pointers.values();
      if (interrupted || pointers.size !== 1 || first === undefined) return;
      const dx = first.dx.get();
      if (dx < -60) row.open();
      if (dx > 60) row.close();
      if (Math.abs(dx) > 60) preventClick();
    },
  });
  // ...
}
  • The first finger decides who hears the Gesture: the row's zone, then each zone around it, up to the first trapped one.
  • onEnd sees every finger, lifted ones included, so finger count and distance are read once the touch is over.
  • interrupted means the browser took the touch, for example to scroll. Treat it as a cancel.
  • The browser still decides whether a release clicks; preventClick() stops it once the app has acted.

Open a sidebar with a swipe

A sidebar Pattern returns motion values; the app renders them. The hook sits inside the zone that covers the screen, so a Swipe right anywhere opens it and a Swipe back anywhere closes it. edge: 24 would open it only from the left edge instead, and make touches there always the sidebar's.

import { useSidebar } from '@kstackz/use-gesture';

function Shell({ children }) {
  const [open, setOpen] = useState(false);
  const sidebar = useSidebar({
    side: 'left',
    width: 280,
    open,
    onOpenChange: setOpen,
  });
  return (
    <>
      <motion.div
        className="fixed inset-0 bg-black/40"
        style={{
          opacity: sidebar.progress,
          pointerEvents: open ? 'auto' : 'none',
        }}
        onClick={() => sidebar.setOpen(false)}
      />
      <motion.aside
        className="fixed inset-y-0 left-0 w-[280px]"
        style={{ x: sidebar.x }}
      />
      {children}
    </>
  );
}
  • Two Swipes run inside it: one enabled while closed, one while open.
  • It settles by the release's projected position, so a quick flick opens it from a few px.
  • x animates from the fingers' own velocity, and setOpen animates it too.