Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get e.offsetX on mobile/iPad

There was no offsetX in e.touches[0] when I tried on iPad. Does anyone know where I can get this value of offsetX?

like image 211
EasonBlack Avatar asked Jul 02 '12 04:07

EasonBlack


1 Answers

The correct answer based on the comments in the suggested answer:

e.offsetX = e.touches[0].pageX - e.touches[0].target.offsetLeft;     
e.offsetY = e.touches[0].pageY - e.touches[0].target.offsetTop;

This ignores any transformations such as rotations or scaling. Also be sure to check if there are any touches.

like image 176
Melle Avatar answered Oct 11 '22 05:10

Melle