0

I'd like to have a gesture in js, where you can tap multiple times with two fingers and get a result that shows your action. It works perfectly fine if you set the attribute pointers to 1 (tap with 1 finger) or if you remove requireFailure().

You can test the code over here, tapping with two fingers works on your smartphone or an emulator: http://codepen.io/JanIngwer/pen/eNwOPO

  mc.add(new Hammer.Tap({ event: 'tripletap', taps: 3, interval: 800, posThreshold: 100, pointers: 2  }));
  mc.add(new Hammer.Tap({ event: 'doubletap', taps: 2, interval: 800, posThreshold: 100, pointers: 2  }));
  mc.add(new Hammer.Tap({ event: 'singletap',  interval: 800, posThreshold: 100, pointers: 2}));


   mc.get('tripletap').recognizeWith(['doubletap', 'singletap']);
   mc.get('doubletap').recognizeWith('singletap');

   mc.get('doubletap').requireFailure('tripletap');
   mc.get('singletap').requireFailure(['tripletap', 'doubletap']);
janIngwer
  • 1
  • 1

1 Answers1

0

You just need to expand the tappable area and restrict to a single pointer. This allows a sigle double or triple executed my multiple fingers to work.

http://codepen.io/anon/pen/PPYvqo

mc.add(new Hammer.Tap({ event: 'ragetap', taps: 5, interval: 800, posThreshold: 1000, pointers: 1 }));
mc.add(new Hammer.Tap({ event: 'tripletap', taps: 3, interval: 800, posThreshold: 1000, pointers: 1  }));
mc.add(new Hammer.Tap({ event: 'doubletap', taps: 2, interval: 800, posThreshold: 1000, pointers: 1  }));
mc.add(new Hammer.Tap({ event: 'singletap',  interval: 800, posThreshold: 1000, pointers: 1}));

Expanding the recognized area also makes this work when requiring multiple pointers.

http://codepen.io/anon/pen/ZbzNbX

runspired
  • 2,642
  • 1
  • 19
  • 24
  • Thanks for the answer, expanding the tappable are helped a bit. However, the main problem was my device. It worked perfectly fine on an iPhone but not on my Android. – janIngwer Aug 30 '15 at 20:14
  • @janIngwer you may want to consider device specific thresholds, pixel density can affect things. Also, if you can repo something not working on a specific device that works as expected everywhere else, open a ticket on github and we'll address it. Which android version and browser? – runspired Aug 31 '15 at 22:11