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

intent-click

v0.1.0

Published

Detect intentional clicks vs accidental taps on touchscreens. Adaptive threshold, ghost click suppression, scroll intent detection.

Readme

intent-click

npm version npm downloads License: MIT

Detect intentional clicks vs accidental taps on touchscreens. Adaptive threshold, ghost click suppression, scroll intent detection.

Why?

On touchscreens, accidental taps are common:

  • User scrolls, finger lands on a button → click fires
  • Drag gesture slightly moved → browser still fires click
  • iOS Safari ghost clicks 300ms after touchend → hits element underneath

Standard solutions don't work:

  • e.preventDefault() — breaks scrolling
  • touch-action: manipulation — doesn't solve drag-vs-click
  • fastclick — deprecated, only solved 300ms delay

intent-click distinguishes intentional clicks from:

  • Drag gestures (movement > threshold)
  • Scroll intents (vertical movement > 10px)
  • Ghost clicks (same coords within 400ms)
  • Long presses (>500ms without movement)
  • Concurrent pointers (pinch-zoom started)

Install

npm install intent-click

Quick Start

import { useIntentClick } from 'intent-click/react';

// React
const ref = useIntentClick<HTMLButtonElement>((event) => {
    // Guaranteed: intentional click
    deleteAccount();
}, { threshold: 'auto' });

<button ref={ref}>Delete Account</button>
// Vanilla JS
import { onIntentClick } from 'intent-click/vanilla';

const off = onIntentClick(buttonEl, () => {
    deleteAccount();
}, { threshold: 'auto' });

Features

  • ~800 bytes gzip
  • Zero runtime dependencies
  • Adaptive threshold: 4px × devicePixelRatio on desktop, 6px × devicePixelRatio on mobile
  • Ghost click suppression: 400ms dead zone on same coords ±5px
  • Scroll intent detection: vertical movement > 10px → scroll, not click
  • Long press discrimination: >500ms without movement → onLongPress
  • Concurrent pointer rejection: multi-touch → cancel
  • SSR-safe: returns null on server, hydrates in browser
  • TypeScript-first: full type inference
  • Framework adapters: React, Vue, Svelte, Solid, Angular, vanilla JS

API

interface IntentClickOptions {
    // Movement threshold in CSS pixels. 'auto' = adaptive
    threshold?: number | 'auto';
    
    // Duration in ms after which it's considered a long press
    longPressDelay?: number;
    
    // Callback when long press is detected
    onLongPress?: (event: PointerEvent) => void;
    
    // Callback when intent is cancelled
    onIntentCancel?: (reason: IntentCancelReason) => void;
}

type IntentCancelReason = 
    | 'drag'              // Movement exceeded threshold
    | 'scroll'            // Vertical movement > 10px
    | 'concurrent-pointer' // Second pointer appeared
    | 'pointercancel'     // OS intercepted gesture
    | 'timeout';          // (reserved)

How It Works

  1. PointerEvent pipeline: single entry point for mouse/touch/pen
  2. FSM: IDLE → PENDING → MOVING → DECIDED
  3. Adaptive threshold: baseThreshold × devicePixelRatio
  4. Ghost click suppression: track last coords, block ±5px for 400ms
  5. Scroll intent: vertical movement > 10px → cancel
  6. Long press: >500ms without movement → onLongPress

Framework Adapters

Docs

Support

See Funding.

License

MIT