Giter Site home page Giter Site logo

fingers.js's Introduction

Fingers.js

A javascript library for simultaneous touch gestures

Fingers.js is a small javascript library that detects and fire gesture events on DOM objects.
This library detects classical gestures: Tap, Hold, Swipe, Pinch, Drag, Rotate, Scale.
It also detects multiple gestures on different objects in the same time.

Features

  • Light library (less than 4kb minified and gzipped)
  • Work with mouse devices (1 finger) and touch devices (multiple fingers)
  • Detect action gestures (Tap, MultipleTap, Hold, Swipe, Pinch) with as many number as you want
  • Detect movement gestures (Drag, Rotate, Scale)
  • Detect raw gestures (Fingers object managed)
  • Multiple gestures in same time (You can drag 2 different objects, rotate a third and swipe a fourth in same time)
  • Easy to add your custom gestures.
  • AMD/CommonJS support

Usage

Fingers.js is simple to use. Just create an instance of Fingers on the wanted DOM object, then register the gestures you want.

var element = document.getElementById('el_id');
var fingers = new Fingers(element);
var gesture1 = fingers.addGesture(Fingers.gesture.Tap);
var gesture2 = fingers.addGesture(Fingers.gesture.Hold);

Gestures can have many handlers

var element = document.getElementById('el_id');
var fingers = new Fingers(element);
var gesture1 = fingers.addGesture(Fingers.gesture.Tap);
gesture1.addHandler(function(eventType, data, fingerList) {
    alert('Tap 1');
});
gesture1.addHandler(function(eventType, data, fingerList) {
    alert('Tap 2');
});

Gestures handling mathods are chainable

var element = document.getElementById('el_id');
new Fingers(element)
    .addGesture(Fingers.gesture.Tap)
    .addHandler(function(eventType, data, fingerList) {alert('Tap 1');})
    .addHandler(function(eventType, data, fingerList) {alert('Tap 2');})
    .addHandler(function(eventType, data, fingerList) {alert('Tap 3');});

Gesture

The following gestures are detected;

  • hold (1 .. N fingers)
  • tap (1 .. N fingers) and multiple taps (1 .. N successive taps)
  • swipe (1 .. N fingers)
  • Pinch (1 .. N fingers)
  • drag (1 finger)
  • rotate (2 fingers)
  • scale (2 fingers)
  • transform (rotate and scale) (2 fingers)
  • raw (each finger is seen independently)

See custom gestures for gesture details.

Finger

Finger object is accessible from Gesture events
It contains all the informations about the finger from its beginning until its end. It provides informations about:

  • it time
  • its position
  • its moving direction
  • its moving velocity

Informations are always available from Finger start or from Finger last move (ex: current velocity and average velocity)

Examples

Examples are available in /tests/manual folder. Try if on PC (but only with on finger) or on a Smartphone / Tablet with all your fingers, then enjoy it.

fingers.js's People

Contributors

paztis avatar

Stargazers

Etaro avatar 云峰 avatar John Magdy Lotfy Kamel avatar Kevin avatar  avatar  avatar  avatar MindView avatar Sven avatar  avatar Michelle Colin avatar Patrik Nyblad avatar IMarty avatar Nic Mulvaney avatar Florian avatar Vitaliy avatar Kilian avatar  avatar Andy Edmonds avatar Donghua Li avatar kaiinui avatar azu avatar  avatar Charandas avatar

Watchers

liu yi avatar  avatar  avatar

fingers.js's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.