views:

168

answers:

2

I am doing iphone web development and I've noticed that: gesture events can also be touch events, which means a touch event handler also fires up when there is a gesture event.

Any way that I can add specific event handler to gesture (not touch)? Or how can I know if this is a pure touch event or a pure gesture event?

A: 

I am not sure the specifics on this but it looks like there are 3 events fired in a gesture.

-touchstart

-touchmove

-touchend

Ultimately your touch end will fire. What you can do is create a threshold amount between your star and end. And trigger a custom event if the (x,y) difference is past a certain amount.

Joshmattvander
How to avoid these 3 events when doing gesture?
Mickey Shine
A: 

Edit: This was an answer for your original revision that asked if something is a "pure touch event". It won't help you with your changed question on getting pure gesture events.

Listen for gesture events and have a gesturing boolean that you check during touch events that is set to true by the event handler for the gesture events and set back to false by the event handler for the touch events if it is true.

I have not researched at all about these events, but here's a sample implementation:

var gesturing = false;
document.addEventListener(aTouchEventName, function () {
  if (gesturing) {
    return gesturing = false;
  }
  // your touch event handler code here
}, false);
document.addEventListener(aGestureEventName, function () {
  gesturing = true;
}, false);
Eli Grey
thank you for your answer. I'll give it a try
Mickey Shine