6

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!

1 Answer 1

11

You will need to cheat a bit, I made a working example for you: http://jsfiddle.net/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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.