Skip to content

Instantly share code, notes, and snippets.

@elevateweb
elevateweb / README.md
Last active December 11, 2015 05:49 — forked from mathiasbynens/README.md
Added distance option - To prevent the left and right from firing on slight touch. Usage: $(document).ready(function() { $('html').swipe({ 'threshold': { 'x': 30, 'y': 180 }, 'distance': { 'x': 100, 'y': 0 } }) });

Improved swipe gestures plugin for jQuery

What was changed (compared to the original v0.1.2):

  • Don’t modify the default settings internally.
  • Merge the options recursively (deep copy) so that the custom threshold values actually get used.
  • Allow overriding the options globally through $.fn.swipe.options.
  • Use namespaced jQuery events (using the swipe namespace) instead of DOM2 addEventListener to prevent errors in old IEs.
  • Simplified and optimized code.
  • Changed swipeLeft and swipeRight functions to be called within the context of the bound element. Thanks, @kswedberg!