From 5bd6a5227dfa5cecc7a3b77c58d379c9f0d4c94a Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Wed, 26 Mar 2014 09:53:50 -0400 Subject: [PATCH] Add config option for event prevention [#1] --- README.md | 1 + jquery.detect_swipe.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f259186..575dfe1 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,4 @@ This won't have any effect on non-touch devices. You can rely on: 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. diff --git a/jquery.detect_swipe.js b/jquery.detect_swipe.js index b679098..bb8b54e 100644 --- a/jquery.detect_swipe.js +++ b/jquery.detect_swipe.js @@ -1,5 +1,5 @@ /** - * jquery.detectSwipe v2.0 + * jquery.detectSwipe v2.1 * jQuery Plugin to obtain touch gestures from iPhone, iPod Touch, iPad and Android * http://github.com/marcandre/detect_swipe * Based on touchwipe by Andreas Waltl, netCU Internetagentur (http://www.netcu.de) @@ -7,8 +7,9 @@ (function($) { $.detectSwipe = { - version: '2.0.0', + version: '2.1.0', enabled: 'ontouchstart' in document.documentElement, + preventDefault: true, threshold: 20 }; @@ -17,7 +18,7 @@ isMoving = false; function onTouchMove(e) { - e.preventDefault(); + if ($.detectSwipe.preventDefault) { e.preventDefault(); } if(isMoving) { var x = e.touches[0].pageX; var y = e.touches[0].pageY;