TouchEvent.touches
概要
语法
var touches = touchEvent.touches;
返回值
示例
此示例说明 TouchEvent
对象的 TouchEvent.touches
属性。该TouchEvent.touches
属性是一个 TouchList
对象,并包含 Touch
当前接触表面的每个接触点的对象列表。
在下面的代码片段中,touchstart
事件处理程序会检查 TouchEvent.touches
列表的长度,以确定激活的触摸点的数量,然后根据触摸点的数量调用不同的处理程序。
someElement.addEventListener('touchstart', function(e) {
// Invoke the appropriate handler depending on the
// number of touch points.
switch (e.touches.length) {
case 1: handle_one_touch(e); break;
case 2: handle_two_touches(e); break;
case 3: handle_three_touches(e); break;
default: console.log("Not supported"); break;
}
}, false);
规范
Specification |
---|
Touch Events # dom-touchevent-touches |
浏览器兼容性
BCD tables only load in the browser