Touch

Touch 对象表示在触控设备上的触摸点。通常是指手指或者触控笔在触屏设备或者触摸板上的操作。

对象属性 Touch.radiusX, Touch.radiusY, 和 Touch.rotationAngle 表示用户触摸操作所作用的区域,即触摸区域。这些属性对于处理类似于手指触摸之类的不精确操作很有帮助。这些属性可以表示出一个尽可能匹配触控区域的椭圆形(例如用户的指尖触控)。 

注意: 以下很多属性的值需要依赖硬件设备去获取,例如,如果设备本身不支持侦测压感,那么 force 属性的值将始终是0,对于 radiusXradiusY 来说同样可能有这种情况,如果设备认为触点只是一个点而不是一个面, 它们始终为1。 

构造函数

Touch()
创建一个Touch对象。

属性

这个接口没有父类,不继承任何属性。

基本属性

Touch.identifier只读
Touch 对象的唯一标识符。 一次触摸动作(例如手指触摸)在平面上移动的整个过程中, 该标识符不变。可以根据它来判断跟踪的是否是同一次触摸过程。
Touch.screenX只读
触点相对于屏幕左边缘的X坐标。
Touch.screenY只读
触点相对于屏幕上边缘的Y坐标。
Touch.clientX只读
触点相对于可见视区(visual viewport)左边缘的X坐标。不包括任何滚动偏移。
Touch.clientY只读
触点相对于可见视区(visual viewport)上边缘的Y坐标。不包括任何滚动偏移。
Touch.pageX只读
触点相对于HTML文档左边缘的X坐标。当存在水平滚动的偏移时, 这个值包含了水平滚动的偏移。
Touch.pageY只读
触点相对于HTML文档上边缘的Y坐标。当存在垂直滚动的偏移时, 这个值包含了垂直滚动的偏移。
Touch.target只读
返回触摸点最初接触的 Element,即使这个触摸点已经移出那个元素的交互区域。需要注意的是, 如果这个元素在触摸过程中被移除, 这个事件仍然会指向它, 因此这个事件也不会冒泡到 windowdocument 对象。因此, 如果有元素在触摸过程中可能被移除, 最佳实践是将触摸事件的监听器绑定到这个元素本身, 防止元素被移除后, 无法再从它的上一级元素上侦测到从该元素冒泡的事件。

触摸区域

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

Touch.radiusX只读
返回能够包围接触区域的最小椭圆的水平轴(X轴)半径。这个值的单位和 screenX 相同
Touch.radiusY只读
返回能够包围接触区域的最小椭圆的垂直轴(Y轴)半径。这个值的单位和 screenY 相同。
Touch.rotationAngle只读
返回一个角度值,表示上述由radiusXradiusY 描述的椭圆为了尽可能精确地覆盖用户与平面之间的接触区域而需要顺时针旋转的角度。
Touch.force只读
返回用户对触摸平面的压力大小,是一个从0.0(没有压力)到1.0(最大压力)的浮点数。

Methods

这个接口没有方法,也没有父类,不继承任何方法。

示例

请看 example on the main Touch events article

规范

规范 状态 注释
Touch Events – Level 2
Touch
Draft 加入 radiusXradiusYrotationAngleforce 属性,和 Touch() 构造函数。
Touch Events
Touch
Recommendation 初始定义。

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
TouchChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
Touch() constructor
Experimental
Chrome Full support 48Edge Full support 79Firefox Full support 46IE No support NoOpera Full support 35Safari No support NoWebView Android Full support 48Chrome Android Full support 48Firefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 5.0
clientXChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
clientYChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
force
Experimental
Chrome Full support YesEdge Full support ≤79Firefox Full support YesIE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
identifierChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
pageXChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
pageYChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
radiusX
Experimental
Chrome Full support 43Edge Full support ≤79Firefox ? IE No support NoOpera Full support YesSafari No support NoWebView Android Full support 43Chrome Android Full support 43Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 4.0
radiusY
Experimental
Chrome Full support 43Edge Full support ≤79Firefox ? IE No support NoOpera Full support YesSafari No support NoWebView Android Full support 43Chrome Android Full support 43Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 4.0
rotationAngle
Experimental
Chrome Full support 43Edge Full support ≤79Firefox ? IE No support NoOpera Full support YesSafari No support NoWebView Android Full support 43Chrome Android Full support 43Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 4.0
screenXChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
screenYChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
targetChrome Full support 22Edge Full support ≤18Firefox Full support 52
Notes
Full support 52
Notes
Notes Touch events support has been fixed and reenabled in Windows desktop platforms.
No support 18 — 24
Notes
Notes Web compatibility issues seen in bug 888304.
IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.

相关链接