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 🙏

© 2025 – Pkg Stats / Ryan Hefner

pinchable

v0.3.2

Published

Lightweight, dependency-free library for smooth mobile pinch-zoom and panning on any HTML element.

Downloads

25

Readme

Pinchable

Pinchable is a lightweight, dependency-free JavaScript library that adds smooth pinch-zoom and panning to any HTML element — perfect for mobile galleries.

npm Bundle size License: MIT


Demos

Try Pinchable live:

  • Playground → https://pinch-six.vercel.app/
  • React demo → https://pinch-react-demo.vercel.app/
  • Vue demo → https://pinch-vue-demo.vercel.app/

Try it on your phone

Scan to open the live demo:

| Playground | React demo | Vue demo | | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | | QR Code | QR Code | QR Code |


Features

  • Smooth pinch-zoom anchored to touch center
  • Pan with edge clamping and threshold smoothing
  • Programmatic zooming via focus({ zoom, to }) using normalized [0–1] coordinates
  • Toggle gestures dynamically with setEnabled()
  • Event system: "start", "pinch", "end" + unsubscribe() helpers
  • Clean teardown with dispose()
  • Works with any DOM element — no frameworks, no dependencies

Installation

npm install pinchable

or

yarn add pinchable

Basic Usage

import { Pinchable } from "pinchable";

const container = document.getElementById("photo")!;

const pinchable = new Pinchable(container, {
    maxZoom: 3,
    minZoom: 0.5,
    edgeZoomThreshold: 0.2,
    nearZeroZoomThreshold: 0.07,
    shiftThreshold: 10,
    velocity: 0.7,
    applyTime: 400,
});

// Zoom to center
pinchable.focus({ zoom: 2, to: { x: 0.5, y: 0.5 } });

// Disable or enable gestures
pinchable.setEnabled(false);
pinchable.setEnabled(true);

// Subscribe to events
const unsubscribePinch = pinchable.subscribe("pinch", (zoom, shift) => {
    console.log("zoom", zoom, "shift", shift);
});

// Cleanup
unsubscribePinch();
pinchable.dispose();

API Reference

| Method | Description | | ------------------------------ | --------------------------------------------------------------------------- | | focus({ zoom, to }) | Programmatically zoom to a specific normalized point | | setEnabled(enabled: boolean) | Enable or disable gestures | | subscribe(event, handler) | Listen to "start", "pinch", or "end" events (returns unsubscribe()) | | dispose() | Remove listeners and reset element |

Options

| Option | Default | Description | | ----------------------- | ------- | ---------------------------------------------- | | maxZoom | 3 | Maximum zoom factor | | minZoom | 1 | Minimum zoom factor | | edgeZoomThreshold | 0.2 | Overshoot tolerance before clamping | | nearZeroZoomThreshold | 0.07 | Smoothing zone near zoom = 1 | | shiftThreshold | 10 | Extra pixels beyond edges before clamping | | velocity | 0.7 | Pinch sensitivity | | applyTime | 400 | Duration (ms) for programmatic zoom transition |


Compatibility

  • Touch devices only
  • Based on the Pointer Events API
  • Tested on iOS Safari and Android Chrome

Integrations


Development

git clone https://github.com/AlexanderShushunov/pinchable
cd pinch
npm install
npm run dev

License

MIT © Alexander Shushunov


Keywords: pinch zoom, gesture, touch, pan, mobile, pinchable, pinch-zoom, pointer events, no dependencies, vanilla js