随机识别Jquery移动触摸事件

时间:2012-11-10 20:47:58

标签: javascript api jquery-mobile touch

我想对识别IPAD的触摸事件采取行动。 问题是,即使触摸一次,触摸事件也会被多次调用。

handleEvent: function (e) {
var that = this;
//console.log("---------------------------------handle event ");
switch(e.type) {
case START_EV:
if (!hasTouch && e.button !== 0) return;
that._start(e);
break;
case MOVE_EV: that._move(e); break;
case END_EV:
case CANCEL_EV: that._end(e); break;
case RESIZE_EV: that._resize(); break;
case 'mouseout': that._mouseout(e); break;
case 'webkitTransitionEnd': that._transitionEnd(e); break;
}
}

如何只识别一次事件。

谢谢, Vaibhav

1 个答案:

答案 0 :(得分:0)

jQuery对触摸事件没有任何特殊之处,但您可以使用以下事件轻松构建自己的事件

touchstart touchmove touchend touchcancel

例如,touchmove(取自here

document.addEventListener('touchmove',function(e){     e.preventDefault();     var touch = e.touches [0];     提醒(touch.pageX +“ - ”+ touch.pageY); },false);