An Array
of all the current touch points on a touchscreen device.
The touches
array is empty by default. When the user touches their screen, a new touch point is tracked and added to the array. Touch points are Objects
with the following properties:
// Iterate over the touches array.
for (let touch of touches) {
// x-coordinate relative to the top-left
// corner of the canvas.
console.log(touch.x);
// y-coordinate relative to the top-left
// corner of the canvas.
console.log(touch.y);
// x-coordinate relative to the top-left
// corner of the browser.
console.log(touch.winX);
// y-coordinate relative to the top-left
// corner of the browser.
console.log(touch.winY);
// ID number
console.log(touch.id);
}
Examples
Notice any errors or typos? Please let us know. Please feel free to edit src/events/touch.js and open a pull request!
Related References
touchEnded
A function that's called once each time a screen touch ends.
touchMoved
A function that's called when the user touches the screen and moves.
touchStarted
A function that's called once each time the user touches the screen.
touches
An Array of all the current touch points on a touchscreen device.