Touchmove与Phonegap [英] Touchmove with Phonegap

查看:202
本文介绍了Touchmove与Phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Phonegap和JQuery中的Android应用程序上真的很苦恼。



我想做的就是将touchmove绑定到一个元素,然后检查X和Y坐标移动我的手指(一个拖动,基本上)

  $('#someElm')。bind('touchmove' ,function(event){
//代码here ..!
});

touchmove在触摸屏幕时触发,但是我真的不知道事件是 - 我尝试过event.screenX,event.pageX,但不工作。



任何想法?



http://developer.apple.com/library/IOS/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.htmlrel =nofollow> http://developer.apple.com/library/IOS/#



您想要的是:










$ b

  var x = event.touches [0] .pageX; 
var y = event.touches [0] .pageY;

如果你是在Android上运行,你还需要取消touchmove事件,以获得新的,而触摸。不要问我为什么...


I'm really struggling on an Android app in Phonegap and JQuery.

All I want to do is bind a touchmove to an element and then check the X and Y coordinates as I move my finger (a drag, basically)

$('#someElm').bind('touchmove',function(event){
        //Code here..!
});

The touchmove fires when I touch the screen, but then I don't really know what the objects of the event are - I've tried event.screenX, event.pageX, but the don't work.

Any ideas?

解决方案

Here the reference for mobile safari (android is basically the same):

http://developer.apple.com/library/IOS/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html

what you want is:

var x = event.touches[0].pageX;
var y = event.touches[0].pageY;

If you are running on android you also need to cancel the touchmove event to get new ones while touching. Don't ask me why...

这篇关于Touchmove与Phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆