PointerEvent - Web API 接口参考 编辑
PointerEvent 接口代表了由 指针 引发的DOM事件的状态,包括接触点的位置,引发事件的设备类型,接触表面受到的压力等。
指针 是输入设备的硬件层抽象(比如鼠标,触摸笔,或触摸屏上的一个触摸点)。指针 能指向一个具体表面(如屏幕)上的一个(或一组)坐标。
指针的 击中检测 指浏览器用来检测 指针事件的目标元素的过程。大多数情况下,这个目标元素是由 指针的位置和元素在文章中的位置和分层共同决定的。
Constructors
PointerEvent()
- 创建一个合成的且不可信的 PointerEvent。
Properties
该接口属性继承自 MouseEvent
和 Event
.
PointerEvent.pointerId
只读- 触发事件的 pointer 的唯一标识符。
PointerEvent.width
只读- Pointer 的接触面的 CSS 像素宽度(X轴上的大小)。
PointerEvent.height
只读- Pointer 的接触面的 CSS 像素高度(Y轴上的大小)。
PointerEvent.pressure
只读- 归一化后的 pointer 压力值,范围在 [0,1] 区间。其中 0 和 1 分别代表硬件能够检测的最小和最大压力。
PointerEvent.tangentialPressure
只读- 归一化后的切向压力值(也称为桶压或cylinder stress),范围在 [-1, 1] 区间,0表示控制设备中立状态时的值。
PointerEvent.tiltX
只读- 由输入设备(如手写笔)与 Y 轴构成的平面,和 Y-Z 平面之间的夹角(取值在 [-90, 90] 区间)。
PointerEvent.tiltY
只读- 由输入设备(如手写笔)与 X 轴构成的平面,和 X-Z 平面之间的夹角(取值在 [-90, 90] 区间)。
PointerEvent.twist
只读- 输入设备(如手写笔)围绕自身主轴顺时针旋转的角度,取值范围是 [0, 359] 度。
PointerEvent.pointerType
只读- 表示触发事件的设备类型(鼠标,触控笔,触摸板等)。
PointerEvent.isPrimary
只读- 标识一个 pointer 是否是当前设备类型的主 pointer。
Pointer event types
The PointerEvent
interface has several event types. To determine which event fired, look at the event's type
property.
event.preventDefault()
to keep the mouse event from being sent as well.pointerover
- This event is fired when a pointing device is moved into an element's hit test boundaries.
pointerenter
- This event is fired when when a pointing device is moved into the hit test boundaries of an element or one of its descendants, including as a result of a pointerdown event from a device that does not support hover (see pointerdown). This event type is similar to pointerover, but differs in that it does not bubble.
pointerdown
- The event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
pointermove
- This event is fired when a pointer changes coordinates.
pointerup
- This event is fired when a pointer is no longer active.
pointercancel
- A browser fires this event if it concludes the pointer will no longer be able to generate events (for example the related device is deactived).
pointerout
- This event is fired for several reasons including: pointing device is moved out of the hit test boundaries of an element; firing the pointerup event for a device that does not support hover (see pointerup); after firing the pointercancel event (see pointercancel); when a pen stylus leaves the hover range detectable by the digitizer.
pointerleave
- This event is fired when a pointing device is moved out of the hit test boundaries of an element. For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer.
gotpointercapture
- This event is fired when an element receives pointer capture.
lostpointercapture
- This event is fired after pointer capture is released for a pointer.
GlobalEventHandlers
GlobalEventHandlers.onpointerover
- A
global event handler
for thepointerover
event. GlobalEventHandlers.onpointerenter
- A
global event handler
for thepointerenter
event. GlobalEventHandlers.onpointerdown
- A
global event handler
for thepointerdown
event. GlobalEventHandlers.onpointermove
- A
global event handler
for thepointermove
event. GlobalEventHandlers.onpointerup
- A
global event handler
for thepointerup
event. GlobalEventHandlers.onpointercancel
- A
global event handler
for thepointercancel
event. GlobalEventHandlers.onpointerout
- A
global event handler
for thepointerout
event. GlobalEventHandlers.onpointerleave
- A
global event handler
for thepointerleave
event.
Example
An Example of each property, event type and global event handler is included in their respective reference page.
Specifications
Specification | Status | Comment |
---|---|---|
Pointer Events – Level 2 PointerEvent | Recommendation | Non-stable version. |
Pointer Events PointerEvent | Obsolete | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论