diff --git a/README.md b/README.md index 575dfe1..01d1927 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,4 @@ 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.ignoreMultiTouch // Should swipes be ignored when they're part a multi-touch gesture? Default is false (swipe events are still triggered) diff --git a/jquery.detect_swipe.js b/jquery.detect_swipe.js index 199ab1f..b3a6038 100644 --- a/jquery.detect_swipe.js +++ b/jquery.detect_swipe.js @@ -10,7 +10,8 @@ version: '2.1.1', enabled: 'ontouchstart' in document.documentElement, preventDefault: true, - threshold: 20 + threshold: 20, + ignoreMultiTouch: false }; var startX, @@ -52,6 +53,11 @@ this.addEventListener('touchmove', onTouchMove, false); this.addEventListener('touchend', onTouchEnd, false); } + else if ($.detectSwipe.ignoreMultiTouch) { + // Ignore move & end events if more than one touch + this.removeEventListener('touchmove', onTouchMove); + this.removeEventListener('touchend', onTouchEnd); + } } function setup() {