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

gesture_recognizer

v1.1.0

Published

An advanced and extensible multi-touch gesture recognizer

Downloads

1

Readme

GestureManager : An advanced and extensible multi-touch gesture recognizer.

Gesture Manager offers out-of-the-box multi touch gesture recognition for tap, long tap, double tap, swipe, pinch and zoom and pinch 5 gestures.

This code is on purpose kept in a structured and long maintainable way. It is not hacky code to keep the codebase artificially small. For each type of Gesture, there's a class dedicated to it. The same Tap gesture recognizer could detect a Tap for one touch and a Tap for ten touches. (Yes, i have tried up to eleven touch points at the same time and works as expected).

The setup is straight:


   // create a gesture recognizer and attach it to a node:
   var gm= new GM.GestureManager(document);
   
   // add a number of gestures and pass in a callback to be notified:
       // a tap gesture for 4 touch points
       gm.on( 
           "tap", 
           function( touch_points ) {
               console.log('4 touch points tap.');
           }, 
           4 );
       
       // a swipe of 3 touch points:
       gm.on( 
           "swipe", 
           function( touch_points, direction ) {
               console.log('3 touch points swipe towards direction ', direction);
           },
           3);

Many different gesture recognizers could be set up for different targets.

Internals

Internally, each gesture is handled by an instance object extending GestureRecognizer. The gesture recognizer is a finite state machine. Bear in mind that all GestureRecognizers are exclusive among them. If a tap 1 fires, a tap 3 can't, and if a swipe 1 fires, a tap 1 can't either be fired.

There's one exception, and is pinch and zoom and swipe 2. Both of these gestures can be recognized at the same time until the swipe will be canceled.

Each of tap, double tap, swipe and long tap can be recognized for an arbitrary number of touch points, and it is guaranteed only one of these gestures will be recognized at the same time.

Gesture pinch and zoom will only be recognized for two touch points and pinch 5 will be recognized only with 5 touch points. Pinch 5 is the multitask gesture on iOS for closing an app.

If you wanted to have a thinner library you could do so by removing recognizers for unnecessary gestures. Objects in the source code for each gesture type are:

  • GR_TAP
  • GR_LongTap
  • GR_DoubleTap
  • GR_Swipe
  • GR_PinchZoom
  • GR_Pinch5

** GR_TAP must exist if GR_LongTap or GR_DoubleTap are needed.

Demo

hyperandroid.github.io/GestureManager/index.html

Changelog

v.1.1.0 Typescript rewrite. Added package details. v.1.0.0 stable version released.