Gerrproger / Tap

Execute code on the element tap!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tap

Execute code on the element tap!

You need jQuery to use this!

Usage

You can start listening for the 'tap' event like this:

$(function(){
  $('#someBlock').tap(function(){ doSomething(); });
});

To unsubscribe from all tap events on the block use the 'off' parameter:

$(function(){
  $('#someBlock').tap('off');
});

You can call all callbacks just as simple:

$(function(){
  $('#someBlock').tap();
});

Options

You can also set two options for the plugin:

delay (default: 200)
Allowable value in milliseconds between the 'touchstart' and 'touchend' events to call your function

offset (default: 4)
Allowable offset in pixels between the 'touchstart' and 'touchend' positions to call your function

$(function(){
  $('#someBlock').tap(function(){ console.log('Tapped', this); }, {delay: 1000, offset: 10});
});

About

Execute code on the element tap!


Languages

Language:JavaScript 100.0%