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

zero-drag

v1.0.0-b5

Published

Minimalist abstraction of drag'n'drop interactions

Downloads

7

Readme

zero-drag

A minimalist abstraction of drag-and-drop interactions only - without abstracting the effects. (why?)

Purpose-built for custom in-app drag-and-drop UI - if you need to exchange data/files with the desktop, this is not the library you're looking for.

Features:

  • Generates drag-and-drop event listeners exposing simple start/drag/drop hooks
  • Minimally abstracts dragged item and drop-target selection
  • Reports drag distances and target locations in various useful ways
  • Optional drag threshold (in pixels) before triggering your start hook
  • Optional delayed re-targeting (improves user experience by tracking user intent)
  • Small: just over 1K
  • Works basically anywhere
  • Written in Typescript: fully type-hinted

TODO: tests, touch events, exchanging files/data with the desktop? (contributions welcome.)

Examples

Some basic examples are available here:

https://codesandbox.io/s/4jw0o0ox4x

Disclaimer: I am not a designer, so this looks like a programmer made it. (contributions welcome!)

Install

To install in your project:

npm install zero-drag --save

To import from Typescript:

import { makeListener } from "zero-drag";

Use auto-completion and refer to inline documentation for usage and API details.

Why?

Because reasons:

  • Correctly implementing drag-and-drop interactions is difficult, error-prone and distracting.
  • Implementing the effects of those interactions is already easy - there's no reason to abstract that.
  • Cleanly separating the complexity of drag-and-drop from potentially complex effects make sense either way.
  • Avoiding the implementation of any effects makes this library useful in many contexts, including plain DOM as well as most view-libraries/frameworks.

Alternatives

Some alternative libs and how they differ:

  • dragula - more high-level library implementing things like sort-order and visual effects; bridges to React and Angular.
  • drag-on-drop - larger, more high-level library implementing sortable lists and trees; bridge to React.
  • drag-drop - uses HTML5 drag-events - if you need to exchange data and files with the desktop, this may be the lib you want.