Skip to content

ajam/detect_swipe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

jquery.detectSwipe

Gives easy access to left/right/up/down swipe events for iOS and other touch devices.

Based on Andreas Waltl's jQuery TouchWipe.

How to use

$(".selector").on('swipeleft',  function(){ /*...*/ })
        .on('swiperight', function(){ /*...*/ })
        .on('swipeup',    function(){ /*...*/ })
        .on('swipedown',  function(){ /*...*/ });

This won't have any effect on non-touch devices. You can rely on:

$.detectSwipe.enabled // true on touch devices, false otherwise

Global setting:

$.detectSwipe.threshold // The number of pixels your finger must move to trigger a swipe event.  Defaults is 20.
$.detectSwipe.preventDefault // Should touchmove events be prevented?  Defaults to true.

What's in this fork?

A new global setting!
$.detectSwipe.swipeExceptionCondition

In case there are situations where you don't want swipe to be enabled, like you have an overflow container that you want to take the scroll. Pass this a function that returns true when that exception condition is met. Here's an example

$.detectSwipe.swipeExceptionCondition = function(){
	return ($('body').attr('data-side-drawer-open') == 'true' || $('body').attr('data-side-drawer-state') == 'changing' );
}
And pinch support!

You can now do

$(".selector").on('pinchin',  function(){ /*...*/ });

This currently fires on both pinching in and pinching out, but it will soon differentiate.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%