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

javascript - jQuery mobile: clientX and clientY and the taphold event - Stack Overflow

programmeradmin0浏览0评论

I'm using the taphold event in my project and need the coordinates of the point where the user tapped. Unfortunately, event.clientX and event.clientY are undefined (cp. my example here). Is there a possibility to get these coordinates similar to the onclick-event?

Thanks in advance!

I'm using the taphold event in my project and need the coordinates of the point where the user tapped. Unfortunately, event.clientX and event.clientY are undefined (cp. my example here). Is there a possibility to get these coordinates similar to the onclick-event?

Thanks in advance!

Share Improve this question asked Feb 20, 2013 at 13:20 sbaltessbaltes 4791 gold badge9 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

You will need to cheat a bit, I made a working example for you: http://jsfiddle/Gajotres/STLWn/

$(document).on('vmousedown', function(event){
    holdCords.holdX = event.pageX;
    holdCords.holdY = event.pageY;
});

$(document).on('taphold', function(e){
    alert('X: ' + holdCords.holdX + ' Y: ' + holdCords.holdY ); 
});

var holdCords = {
    holdX : 0,
    holdY : 0
}

Tested on desktop Firefox, Android 4.1.1 Chrome and iPad 6.0

发布评论

评论列表(0)

  1. 暂无评论