test_pinch.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var el,
  2. hammer;
  3. module('Pinch Gesture', {
  4. setup: function() {
  5. el = document.createElement('div');
  6. document.body.appendChild(el);
  7. hammer = new Hammer(el, {recognizers: []});
  8. },
  9. teardown: function() {
  10. document.body.removeChild(el);
  11. hammer.destroy();
  12. }
  13. });
  14. asyncTest('Pinch event flow should be start -> in -> end', function() {
  15. expect(1);
  16. var pinch = new Hammer.Pinch({enable: true, threshold: .1});
  17. hammer.add(pinch);
  18. var eventflow = "";
  19. var isFiredPinchin = false;
  20. hammer.on('pinchstart', function() {
  21. eventflow += "start";
  22. });
  23. hammer.on('pinchin', function() {
  24. if(!isFiredPinchin){
  25. isFiredPinchin = true;
  26. eventflow += "in";
  27. }
  28. });
  29. hammer.on('pinchend', function() {
  30. eventflow += "end";
  31. isFiredPinchin = false;
  32. });
  33. Simulator.gestures.pinch(el, { duration: 500, scale: .5 }, function() {
  34. equal(eventflow,"startinend");
  35. start();
  36. });
  37. });