Skip to content Skip to sidebar Skip to footer

The Touch Event In My Canvas Is Not Working As Intended And I Am Not Able To Identify The Reason Why It Is Not Working

So I am currently trying to create a notebook styled module for a web application. Currently it is working perfectly fine with its mouse event but not when using touch events. //T

Solution 1:

Since touch event can handle multiple touch points, the x and y of the fingers are not described by event.clientX and event.clientY like for mouse. Instead you got event.touches which is an array of coordinates. So in your code, everytime you want to handle touch event, just replace event.clientX by event.touches[0].clientX and event.clientY by event.touches[0].clientY (considering you only want to handle one finger of course)


Post a Comment for "The Touch Event In My Canvas Is Not Working As Intended And I Am Not Able To Identify The Reason Why It Is Not Working"