Skip to content

Commit

Permalink
closes gaps in config and updates tests to match
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired authored and arschmitz committed Nov 11, 2015
1 parent da49a27 commit 70c2902
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/recognizers/press.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/recognizers/swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion src/recognizers/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},

Expand Down
24 changes: 16 additions & 8 deletions tests/unit/test_gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
});

0 comments on commit 70c2902

Please sign in to comment.