Skip to content

supachris28/detect_swipe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery.detectSwipe

Gives easy access to left/right/up/down swipe events for iOS and other touch devices. Also includes swipe from edge functionality.

Based on Andreas Waltl's jQuery TouchWipe.

How to use

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

Edge swipes:

$(".selector").on('swipefromleft',   function(){ /*...*/ })
              .on('swipefromright',  function(){ /*...*/ })
              .on('swipefrombottom', function(){ /*...*/ })
              .on('swipefromtop',    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.
$.detectSwipe.edgethreshold // The number of pixels at the edges of the window that the swipe that should be  
                            // interpreted as an "edge" swipe.  Defaults to 15% of the page width on load.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 72.0%
  • HTML 28.0%