Touchmove与Phonegap [英] Touchmove with Phonegap
问题描述
我在Phonegap和JQuery中的Android应用程序上真的很苦恼。
我想做的就是将touchmove绑定到一个元素,然后检查X和Y坐标移动我的手指(一个拖动,基本上)
$('#someElm')。bind('touchmove' ,function(event){
//代码here ..!
});
touchmove在触摸屏幕时触发,但是我真的不知道事件是 - 我尝试过event.screenX,event.pageX,但不工作。
任何想法?
您想要的是:
$ 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):
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屋!