GithubHelp home page GithubHelp logo

tap-listener's Introduction

Tap listener

Listens to taps

On mobile devices, the click event is triggered after a delay. Tap Listener listens for native touch and pointer events to trigger a callback immediately.

Used in Flickity.

var tapper = new TapListener( element );
tapper.on( 'tap', function( event ) {
  console.log('tap happened');
});

Use TapListener to extend a class.

function Widget() {
  //...
}
// inherit Tap Listener
Widget.prototype = new TapListener();
// or
_.extend( Widget.prototype, TapListener.prototype );

var widgy = new Widget( element );
widgy.on( 'tap', function() {...});

Install

Bower: bower install tap-listener --save

npm: npm install tap-listener

RequireJS

requirejs( [ 'path/to/tap-listener' ], function( TapListener ) {
  var tapper = new TapListener( element );
});

Browserify

var TapListener = require('tap-listener');
var tapper = new TapListener( element );

API

var tapper = new TapListener( element )
// element {Element} - binds tap events to element

tapper.bindTap( element )
// element {Element} - binds tap events to element

tapper.unbindTap()
// unbinds tap events

tapper.on( eventName, callback )
// eventName {String} - tap, pointerDown, pointerMove, pointerUp, pointerCancel
// callback {Function}

function callback( event, pointer ) {...}
// event {Event} - the original mouseup, touchend, or pointerup event
// pointer {Event} or {Touch} - event object with pageX and pageY

tapper.destroy()
// unbinds tap events

MIT license

By Metafizzy

tap-listener's People

Contributors

desandro avatar

Watchers

 avatar  avatar

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.