Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
15
rated 0 times [  18] [ 3]  / answers: 1 / hits: 16236  / 12 Years ago, wed, january 23, 2013, 12:00:00

So I have an element that looks like this:



 ____________________________________
/
| |
| |
+------------------------------------+
| |
| |
| |
+------------------------------------+
| |
| |
____________________________________/


I have attached a touchstart listener to it, like this:



    other_options.addEventListener('touchstart', function(e) {
event.preventDefault();
}, false);


What I want to do, and I've already looked through the values of 'e' but I can't find any value consistent enough (values don't seem right to me when I try them) to do what I want.



I know the size of those rows. I just want to be able to take the Y coordinate of where the touchstart event fired, being 0 the upper coordinate of the element. That way, Math.floor(y / ROW_SIZE) will give me the row the touchstart event was started on.


More From » html

 Answers
4

You have to access like this.



e.touches[0].clientX/clientY.


the number touchs and touch information can be access via e.touches.



Take look at this FAQ.



How to get the x/y coordinates in touch events ?



here is the touch event documentation.



By the way, events will return x/y coordinates relative to the window only. we can't changed that. what you can do this. top= 0 - element.top; x= clientx-top.


[#80682] Tuesday, January 22, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
skylerselenem

Total Points: 282
Total Questions: 101
Total Answers: 107

Location: Nicaragua
Member since Tue, Dec 8, 2020
4 Years ago
;