pressure
只读特性在
PointerEvent
interface indicates the normalized pressure of the pointer input.
var pressure = pointerEvent.pressure;
pressure
0
to
1
, inclusive, where
0
and
1
represent the minimum and maximum pressure the hardware is capable of detecting, respectively. For hardware that does not support pressure, such as a mouse, the value is
0.5
when the pointer is active buttons state and
0
否则。
In this snippet, when a
pointerdown
event is fired, different functions are called depending on the value of the event's
pressure
特性。
someElement.addEventListener('pointerdown', function(event) {
if (event.pressure == 0) {
// No pressure
process_no_pressure(event);
} else if (event.pressure == 1) {
// Maximum pressure
process_max_pressure(event);
} else {
// Default
process_pressure(event);
}
}, false);
| 规范 | 状态 | 注释 |
|---|---|---|
|
指针事件 – 2 级
The definition of 'pressure' in that specification. |
推荐 | 非稳定版本。 |
|
指针事件
The definition of 'pressure' 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 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
pressure
|
Chrome 55 | Edge 12 |
Firefox
59
|
IE
11
|
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
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