开发者

tell pure touch event and pure gesture event apart?

开发者 https://www.devze.com 2022-12-12 19:14 出处:网络
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.

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?


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);


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消