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

xtap

v0.0.1

Published

Super lightweight script (1kb) to detect via Javascript events like 'tap' 'dbltap' 'swipe' 'longtap' 'pinch' 'rotate' on any kind of device.

Downloads

12

Readme

#tap lightweight script (~1kb) to detect via Javascript events like 'tap' 'dbltap' 'longtap' 'swipe' 'pinch' 'rotate' on any kind of device. no dependencies.

##Usage Include the script into your page:

<script src="path/to/tap.js"></script>

Once you have included tap.js you will be able to catch all the new events:

elm.addEventListener('tap',function(e){});
elm.addEventListener('dbltap',function(e){});
elm.addEventListener('longtap',function(e){});
elm.addEventListener('swipe',function(e){});
elm.addEventListener('pinch',function(e){});
elm.addEventListener('rotate',function(e){});

It works with jQuery as well:

$(elm).on('tap',function(e,data){});
$(elm).on('dbltap',function(e,data){});
$(elm).on('longtap',function(e,data){});
$(elm).on('swipe',function(e,data){});
$(elm).on('pinch',function(e,data){});
$(elm).on('rotate',function(e,data){});

Anyway you can combine tap.js with the default javascript touch events:

  • touchmove
  • touchstart
  • touchend
  • touchcancel

To disable the default touch behaviours (zoom on double tap, scroll on swipe...) on a certain element via javascript you can always use the following snippet:

elm.addEventListener('touchmove',function(e){e.preventDefault()}); elm.addEventListener('touchstart',function(e){e.preventDefault()}); elm.addEventListener('touchend',function(e){e.preventDefault()});

##API and Examples

###Event Object Anytime you will use a Tap.js event the callback function will receive a special event object containing the some properties. thoese property consist of two type of property : common property and property specified by event type

  • common property x { Int }: latest x position of pointer at the end of the event y { Int }: latest y position of pointer at the end of the event originalEvent { Object }: the original javascript native event that has been triggered

  • property specified by event type

    distance: distance between the beginning and the end of the swipe gesture. this property is available only for the swipe events

    • x { Int }: the x absolute difference between the beginning and the end of the swipe gesture
    • y { Int }: the y absolute difference between the beginning and the end of the swipe gesture

    velocity: velocity vector when user swipe on the screen. this property is available only for the swipe events

    • x { Int }: the x component of velocity vector
    • y { Int }: the y component of velocity vector

    direction: direction when user swipe on the screen. Only support 'left' 'up' 'down' 'right'. this property is available only for the swipe events.

Examples:

elm.addEventListener('dbltap',function (e){
    console.log(e.x);
    console.log(e.y);
});


elm.addEventListener('swipe',function (e){
    console.log(e.x);
    console.log(e.y);
    console.log(e.distance.x);
    console.log(e.distance.y);
    console.log(e.velocity.x);
    console.log(e.velocity.y);
    console.log(e.direction);
});

// with jQuery

$(elm).on('dbltap',function (e,data){
    console.log(data.x);
    console.log(data.y);
});
$(elm).on('swipeup',function (e,data){
    console.log(e.x);
    console.log(e.y);
    console.log(e.distance.x);
    console.log(e.distance.y);
    console.log(e.velocity.x);
    console.log(e.velocity.y);
    console.log(e.direction);
});

##Browser Support

Actually the script has been tested on all the modern browsers but it need a better testing phase over several platforms: Chrome 29+ Firefox 23+ Opera 12+ Safari 5+

It works on mobile/tablet browsers and on desktop browsers as well.

On the old browsers all the tap.js events cannot be triggered.