How do I get the coordinates that the user touches? I am using xui and Javascript.
On my index.html I do not know how to get the x and y coordinates from a user interaction.
How do I get the coordinates that the user touches? I am using xui and Javascript.
On my index.html I do not know how to get the x and y coordinates from a user interaction.
Copyright © 2021 Jogjafile Inc.
if you use xui for event binding then the event callback function gets
TocuhEvent
object (e) as its parameterNow TouchEvent isn't like MouseEvent where you can have only one input at a time - as TouchEvent object handles multitouch multiple touches at the same time.
To get the touch that was captured on your element you have to get it from
e.touches
- which is all touches currently active on the device,e.targetTouches
- all the touches which are on the current target.a_button
in our example ore.changedTouches
- touches which triggered the event. For touchstart (best responsiveness) you can grab first element ofe.changedTouches
as it will be the touch that triggered yourtouchstart
event to get theTouch
object representing your touch.Now
Touch
object holds all the data you need to get any info on what's happening on the screen.