最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - "touchmove" event on Android &iPhone using PhoneGap - Stack Overflow

programmeradmin1浏览0评论

so basically I want to be able to get the coordinates of the touch when someone swipes across the screen of a touch-enable device powered by iOS or Android.

What I've tried to do so far is as follows.

$('element').bind("touchmove", function(e) {
    $(element2).html(e.pageX + "," + e.pageY);
}

plus I've tried the same with "vmousemove"(the jquery mobile equivalent or so it should be), "mousemove" but to no avail. I only get the coordinates of the the initial and end touch.

Thanks in advance

so basically I want to be able to get the coordinates of the touch when someone swipes across the screen of a touch-enable device powered by iOS or Android.

What I've tried to do so far is as follows.

$('element').bind("touchmove", function(e) {
    $(element2).html(e.pageX + "," + e.pageY);
}

plus I've tried the same with "vmousemove"(the jquery mobile equivalent or so it should be), "mousemove" but to no avail. I only get the coordinates of the the initial and end touch.

Thanks in advance

Share Improve this question asked Feb 17, 2013 at 20:52 Petar VasilevPetar Vasilev 4,7556 gold badges47 silver badges78 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

iOS and Android are muti-touch devices. The interaction is handled using touch events:

https://developer.mozilla/en-US/docs/DOM/Touch_events

You're very close... All you needed was the original Event. jQuery wraps these up for you.

e.g.

$('element').bind("touchmove", function(event) {
   var e = ev.originalEvent;
   var touch = e.touches[0];
   $(element2).html(touch.pageX + "," + touch.pageY);
}

EDIT: I forgot about the touches array... my bad.

发布评论

评论列表(0)

  1. 暂无评论