我试图用一个touchstart事件的jQuery获得X位置,与live函数一起使用?
即
$('#box').live('touchstart', function(e) { var xPos = e.PageX; } );
Run Code Online (Sandbox Code Playgroud)
现在,这可以使用'click'作为事件.如何(不使用alpha jQuery Mobile)我是否通过触摸事件获得它?
有任何想法吗?
谢谢你的帮助.
我们一直在研究iPad应用程序,并使用jQuery Mobile来处理诸如滑动(更改页面)之类的事件.在测试应用程序时,很明显默认的滑动配置变量感觉不对.尝试滚动时滑动太敏感,反之亦然.
我们已经使用了配置变量,但我们不确定我们是否了解每个配置变量的作用.我们制作了一个图形,以帮助我们了解它们如何协同工作.我们是正确理解这个还是遗漏了什么?

我希望你今天很好,我正在尝试计算移动网站上的滑动距离(触摸手势),你将如何计算出用户在屏幕上滑动了多少像素?
$('.cmButtons').live('swipeleft',function(){
console.log("swiped left");
});
Run Code Online (Sandbox Code Playgroud) 我试图让jQuery拖放与iPad touch事件很好地协同工作.我在互联网上找到了这个代码:
function touchHandler(event)
{
var touches = event.changedTouches,
first = touches[0],
type = "";
switch (event.type)
{
case "touchstart": type = "mousedown"; break;
case "touchmove": type = "mousemove"; break;
case "touchend": type = "mouseup"; break;
default: return;
}
//initMouseEvent(type, canBubble, cancelable, view, clickCount,
// screenX, screenY, clientX, clientY, ctrlKey,
// altKey, shiftKey, metaKey, button, relatedTarget);
var simulatedEvent = document.createEvent("MouseEvent");
simulatedEvent.initMouseEvent(type, true, true, window, 1,
first.screenX, first.screenY,
first.clientX, first.clientY, false,
false, false, false, 0/*left*/, null);
first.target.dispatchEvent(simulatedEvent);
event.preventDefault();
}
Run Code Online (Sandbox Code Playgroud)
如果我将touchHandler附加到document …
我在我的PhoneGap应用程序中的链接上绑定现场活动.事件成功触发(通过alert()ing 确认),但似乎任何触摸数据都没有像应该的那样附加到事件对象.这发生在所有触摸事件, - touchstart,touchmove和touchend.
$('a').live('touchend', function(event) {
event.preventDefault();
alert(event.touches.length); // event.touches should be populated!
});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我是使用jQuery.live()的SOL吗?
jquery ×3
javascript ×2
touch ×2
click ×1
events ×1
iphone ×1
jquery-ui ×1
live ×1
touch-event ×1