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

dndtouch2

v1.0.0

Published

from dragdroptouch of Bernardo Castilho

Downloads

49

Readme

DragDropTouch

Polyfill that enables HTML5 drag drop support on mobile (touch) devices.

The HTML5 specification includes support for drag and drop operations. Unfortunately, most mobile browsers do not implement it, so applications that rely on HTML5 drag and drop have reduced functionality when running on mobile devices.

The DragDropTouch class is a polyfill that translates touch events into standard HTML5 drag drop events. If you add the polyfill to your pages, drag and drop operations should work on mobile devices just like they do on the desktop.

Demo

The demo should work on desktop as well as on mobile devices, including iPads and Android tablets.

The top section of the demo is based on a well-known HTML5 drag and drop sample available here:

The following sections demonstrate how the polyfill works with standards-based components that use HTML5 drag and drop. You can use touch to resize and reorder grid columns, data groups, and pivot fields.

Install

Add the DragDropTouch.js polyfill to your page to enable drag and drop on mobile devices:

<script src="DragDropTouch.js"></script>

Polyfill behaviour

The DragDropTouch polyfill attaches listeners to the document's touch events:

  • On touchstart, it checks whether the target element has the draggable attribute or is contained in an element that does. If that is the case, it saves a reference to the "drag source" element and prevents the default handling of the event.
  • On touchmove, it checks whether the touch has moved a certain threshold distance from the origin. If that is the case, it raises the dragstart event and continues monitoring moves to fire dragenter and dragleave.
  • On touchend, it raises the dragend and drop events.

To avoid interfering with the automatic browser translation of some touch events into mouse events, the polyfill performs a few additional tasks:

  • Raise the mousemove, mousedown, mouseup, and click events when the user touches a draggable element but doesn't start dragging,
  • Raise the dblclick event when there's a new touchstart right after a click, and
  • Raise the contextmenu event when the touch lasts a while but the user doesn't start dragging the element.

Thanks

Thanks to Eric Bidelman for the great tutorial on HTML5 drag and drop: [Native HTML5 Drag and Drop] (http://www.html5rocks.com/en/tutorials/dnd/basics/).

Thanks also to Chris Wilson and Paul Kinlan for their article on mouse and touch events: [Touch And Mouse] (http://www.html5rocks.com/en/mobile/touchandmouse/).

Finally, thanks to Tim Ruffles for his iOS shim code which was inspiring: [iOS DragDrop Shim] (https://github.com/timruffles/ios-html5-drag-drop-shim).

License

MIT License