I'm trying to capture the position of the touchstart
relative to an element (".canvas") Is there any possibility to capture this event offsetX
and offsetY
?
$(".canvas").on("mousemove", function(event){
console.log(event.offsetX + " - " + event.offsetY);
})
With click
event: http://jsfiddle.net/jfejc6zw/1/
With touchstart
event (Test it with your mobile or simulator) http://jsfiddle.net/jfejc6zw/2/
Thanks in advance!
If you're already using jQuery, why would you bother with the low level event coordinates? Just use the jQuery .offset() and .position() functions, in the knowledge that jQuery already did all the browser-inconsistency solving.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.