Guys how do i get the clientX and clientY in this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Guys how do i get the clientX and clientY in this code

I tought it was e.clientX but not working cvs.addEventListener('touchstart',(e)=>{ console.dir(e) console.log(e.clientX) })

26th Nov 2021, 9:23 PM
Dagota
Dagota - avatar
2 Answers
+ 3
e.touches[0].clientX TouchEvent is different from MouseEvent. For MouseEvent, only one target; For TouchEvent, more than one target. So need to get the first touch target from touches with [0]
27th Nov 2021, 12:21 AM
Gordon
Gordon - avatar
+ 2
Use pointerdown instead of touchstart
26th Nov 2021, 11:29 PM
Solo
Solo - avatar