diff --git a/src/recognizers/press.js b/src/recognizers/press.js index 853f9c69e..d52f830cf 100644 --- a/src/recognizers/press.js +++ b/src/recognizers/press.js @@ -19,8 +19,8 @@ inherit(PressRecognizer, Recognizer, { defaults: { event: 'press', pointers: 1, - time: 500, // minimal time of the pointer to be pressed - threshold: 5 // a minimal movement is ok, but keep it low + time: 251, // minimal time of the pointer to be pressed + threshold: 9 // a minimal movement is ok, but keep it low }, getTouchAction: function() { diff --git a/src/recognizers/swipe.js b/src/recognizers/swipe.js index eb86abd44..fb3d66c77 100644 --- a/src/recognizers/swipe.js +++ b/src/recognizers/swipe.js @@ -16,7 +16,7 @@ inherit(SwipeRecognizer, AttrRecognizer, { defaults: { event: 'swipe', threshold: 10, - velocity: 0.65, + velocity: 0.3, direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL, pointers: 1 }, diff --git a/src/recognizers/tap.js b/src/recognizers/tap.js index d6a95c120..072d45c94 100644 --- a/src/recognizers/tap.js +++ b/src/recognizers/tap.js @@ -32,7 +32,7 @@ inherit(TapRecognizer, Recognizer, { taps: 1, interval: 300, // max time between the multi-tap taps time: 250, // max time of the pointer to be down (like finger on the screen) - threshold: 2, // a minimal movement is ok, but keep it low + threshold: 9, // a minimal movement is ok, but keep it low posThreshold: 10 // a multi-tap can be a bit off the initial position }, diff --git a/tests/unit/test_gestures.js b/tests/unit/test_gestures.js index 70b18e513..d7c0125f0 100644 --- a/tests/unit/test_gestures.js +++ b/tests/unit/test_gestures.js @@ -37,7 +37,7 @@ module('Gesture recognition', { asyncTest('recognize pan', function() { expect(1); - Simulator.gestures.pan(el, { deltaX: 100, deltaY: 0 }, function() { + Simulator.gestures.pan(el, { duration: 500, deltaX: 100, deltaY: 0 }, function() { start(); deepEqual(events, { pan: true, @@ -179,22 +179,30 @@ asyncTest('recognize rotate and pinch simultaneous', function() { asyncTest('don\'t recognize pan and swipe when moving down, when only horizontal is allowed', function() { expect(1); - Simulator.gestures.swipe(el, { duration: 500, deltaX: 0, deltaZ: 200 }, function() { + Simulator.gestures.swipe(el, { duration: 250, deltaX: 0, deltaZ: 200 }, function() { start(); deepEqual(events, { }); }); }); -asyncTest('don\'t recognize press when a -invalid- tap has been done', function() { +asyncTest('don\'t recognize press if duration is too short.', function() { expect(1); - Simulator.gestures.press(el, { duration: 500 }); + Simulator.gestures.press(el, { duration: 240 }); + setTimeout(function() { - Simulator.gestures.tap(el, { duration: 500 }); - }, 200); + start(); + deepEqual(events, { tap: true }, 'Tap gesture has been recognized.'); + }, 275); +}); + +asyncTest('don\'t recognize tap if duration is too long.', function() { + expect(1); + + Simulator.gestures.tap(el, { duration: 255 }); setTimeout(function() { start(); - deepEqual(events, { }, 'no gesture has been recognized. invalid tap and invalid press.'); - }, 700); + deepEqual(events, { press: true }, 'Press gesture has been recognized.'); + }, 275); });