Touch

Touch interface represents a single contact point on a touch-sensitive device. The contact point is commonly a finger or stylus and the device may be a touchscreen or trackpad.

Touch.radiusX , Touch.radiusY ,和 Touch.rotationAngle describe the area of contact between the user and the screen, the touch area . This can be helpful when dealing with imprecise pointing devices such as fingers. These values are set to describe an ellipse that as closely as possible matches the entire area of contact (such as the user's fingertip).

注意: Many of the properties' values are hardware-dependent; for example, if the device doesn't have a way to detect the amount of pressure placed on the surface, the force value will always be 0. This may also be the case for radiusX and radiusY ; if the hardware reports only a single point, these values will be 1.

构造函数

Touch()
Creates a Touch object.

特性

This interface has no parent, and doesn't inherits or implements any other property.

Basic properties

Touch.identifier 只读
Returns a unique identifier for this Touch object. A given touch point (say, by a finger) will have the same identifier for the duration of its movement around the surface. This lets you ensure that you're tracking the same touch all the time.
Touch.screenX 只读
Returns the X coordinate of the touch point relative to the left edge of the screen.
Touch.screenY 只读
Returns the Y coordinate of the touch point relative to the top edge of the screen.
Touch.clientX 只读
Returns the X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset.
Touch.clientY 只读
Returns the Y coordinate of the touch point relative to the top edge of the browser viewport, not including any scroll offset.
Touch.pageX 只读
Returns the X coordinate of the touch point relative to the left edge of the document. Unlike clientX , this value includes the horizontal scroll offset, if any.
Touch.pageY 只读
Returns the Y coordinate of the touch point relative to the top of the document. Unlike clientY, this value includes the vertical scroll offset, if any.
Touch.target 只读
返回 Element on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of that element or even been removed from the document.

Touch area

这是 实验性技术
检查 浏览器兼容性表格 在生产中使用这之前。

Touch.radiusX 只读
Returns the X radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as screenX .
Touch.radiusY 只读
Returns the Y radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as screenY .
Touch.rotationAngle 只读
Returns the angle (in degrees) that the ellipse described by radiusX and radiusY must be rotated, clockwise, to most accurately cover the area of contact between the user and the surface.
Touch.force 只读
Returns the amount of pressure being applied to the surface by the user, as a float between 0.0 (no pressure) and 1.0 (maximum pressure).

方法

This interface has no method and no parent, and doesn't inherits or implements any method.

规范

规范 状态 Comment
Touch Events – Level 2
The definition of 'Touch' in that specification.
草案 添加 radiusX , radiusY , rotationAngle , force properties, as well as the Touch() 构造函数。
触摸事件
The definition of 'Touch' in that specification.
Recommendation 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Touch Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
Touch() 构造函数
Chrome 48 Edge 79 Firefox 46 IE 不支持 No Opera 35 Safari 不支持 No WebView Android 48 Chrome Android 48 Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android 5.0
clientX Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
clientY Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
force
Chrome Yes Edge ≤79 Firefox Yes IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
identifier Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
pageX Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
pageY Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
radiusX
Chrome 43 Edge ≤79 Firefox ? IE 不支持 No Opera Yes Safari 不支持 No WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
radiusY
Chrome 43 Edge ≤79 Firefox ? IE 不支持 No Opera Yes Safari 不支持 No WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
rotationAngle
Chrome 43 Edge ≤79 Firefox ? IE 不支持 No Opera Yes Safari 不支持 No WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
screenX Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
screenY Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
target Chrome 22 Edge ≤18 Firefox 52
注意事项
52
注意事项
Touch events support has been fixed and reenabled in Windows desktop platforms.
18 — 24
注意事项
Web compatibility issues seen in bug 888304 .
IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 6 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
见实现注意事项。

另请参阅