包含一个触摸屏设备上所有当前触摸点的一个数组 Array
。
touches
数组默认为空。当用户触摸屏幕时,一个新的触摸点会被追踪并添加到这个数组中。触摸点是带有以下属性的对象 Objects
:
// 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);
<p> // y-coordinate relative to the top-left
// corner of the canvas.
console.log(touch.y);</p>
<p> // x-coordinate relative to the top-left
// corner of the browser.
console.log(touch.winX);</p>
<p> // y-coordinate relative to the top-left
// corner of the browser.
console.log(touch.winY);</p>
<p> // ID number
console.log(touch.id);
}
</p>
示例
Notice any errors or typos? Please let us know. Please feel free to edit src/events/touch.js and open a pull request!