tangentialPressure
只读特性在
PointerEvent
interface represents the normalized tangential pressure of the pointer input (also known as barrel pressure or
cylinder stress
).
var tanPressure = pointerEvent.tangentialPressure;
A
float
representing the normalized tangential pressure of the pointer input in the range
-1
to
1
, inclusive, where
0
is the neutral position of the control.
Note that some hardware may only support positive values in the range
0
to
1
. For hardware that does not support tangential pressure, the value will be
0
.
In this snippet, when a
pointerdown
event is fired, different functions are called depending on the value of the event's
tangentialPressure
特性。
someElement.addEventListener('pointerdown', function(event) {
if (event.tangentialPressure == 0) {
// No pressure
process_no_tanPressure(event);
} else if (event.tangentialPressure == 1) {
// Maximum pressure
process_max_tanPressure(event);
} else {
// Default
process_tanPressure(event);
}
}, false);
| 规范 | 状态 | 注释 |
|---|---|---|
|
指针事件 – 2 级
The definition of 'tangentialPressure' 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 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
tangentialPressure
|
Chrome 58 | Edge 79 |
Firefox
59
|
IE No | Opera 45 | Safari 13 | WebView Android 58 | Chrome Android 58 | Firefox Android 54 | Opera Android 43 | Safari iOS 13 | Samsung Internet Android 7.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