pointerId
只读特性在
PointerEvent
interface is an identifier assigned to a given pointer event. The identifier is unique, being different from the identifiers of all other active pointer events. Since the value may be randomly generated, it is not guaranteed to convey any particular meaning.
var id = pointerEvent.pointerId;
id
The pointer event's unique identifier number.
The following code snippet compares a previously saved
pointerId
with the one of the
pointerdown
event that was just fired.
let id; // Let's assume that this is a previously saved pointerId
target.addEventListener('pointerdown', function(event) {
// Compare previous event's ID that was cached
// to current event's ID and handle accordingly
if (id === event.pointerId) process_event(event);
}, false);
| 规范 | 状态 | 注释 |
|---|---|---|
|
指针事件 – 2 级
The definition of 'pointerId' in that specification. |
推荐 | 非稳定版本。 |
|
指针事件
The definition of 'pointerId' in that specification. |
过时 | 初始定义。 |
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
更新 GitHub 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
pointerId
|
Chrome 55 | Edge 12 |
Firefox
59
|
IE 10 | Opera 42 | Safari 13 | WebView Android 55 | Chrome Android 55 | Firefox Android 41 | Opera Android 42 | Safari iOS 13 | Samsung Internet Android 6.0 |
完整支持
用户必须明确启用此特征。
PointerEvent
height
isPrimary
pointerId
pointerType
pressure
tangentialPressure
tiltX
tiltY
twist
width
Element.ongotpointercapture
Element.onlostpointercapture
Element.releasePointerCapture()
Element.setPointerCapture()
GlobalEventHandlers.onpointercancel
GlobalEventHandlers.onpointerdown
GlobalEventHandlers.onpointerenter
GlobalEventHandlers.onpointerleave
GlobalEventHandlers.onpointermove
GlobalEventHandlers.onpointerout
GlobalEventHandlers.onpointerover
GlobalEventHandlers.onpointerup
Navigator.maxTouchPoints