Skip to content

Fingerpointer is a jQuery plugin to provide seperate event handling between touch and pointer devices

License

Notifications You must be signed in to change notification settings

visiongeist/jquery.fingerpointer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jquery.fingerpointer

fingerpointer is a tiny jQuery plugin to provide a simple switch between touch and mouse events. In the case you are planning to use the same web application for touch and desktop clients, you definitely need this plugin.

  • Lightweight (less than 300 bytes)
  • Stops messing up your event space
  • Simply based on jQuery 1.7 on/off methods
  • finger and pointer feels more natural

Example

Usually you would bind a mouse event like that:

$('a').on('click', myFunc);

So far there are no problems since click also works perfectly fine on touch events. Imagine you want to have different events for the same function call on touch devices.

var isTouch = 'ontouchstart' in window; 

if (isTouch) {
	$('a').on('touchstart', myFunc);
} else {
	$('a').on('click', myFunc);
}

Now the way you can achieve that with fingerpointer:

$('a').fipo('touchstart', 'click', myFunc);

Pretty easy, right? But if you have some event calls exclusively for touch or pointer devices you can use this fancy functions:

$('a').finger('touchstart', myFunc);
$('a').pointer('click', myFunc2);

Or just chain them

$('a').finger('touchstart', myFunc)
	.pointer('click', myFunc2);

About

Fingerpointer is a jQuery plugin to provide seperate event handling between touch and pointer devices

Resources

License

Stars

Watchers

Forks

Packages

No packages published