Pointer Events
The PointerEvent() constructor creates a new synthetic
and untrusted PointerEvent object instance.
Syntax
new PointerEvent(type)
new PointerEvent(type, options)
Parameters
type- : A string representing the name of the event (see PointerEvent event types).
options- : An object that, in addition of the properties defined in MouseEvent/MouseEvent, can have the following properties:
pointerId- : A number, defaulting to
0, that sets the value of the instance's PointerEvent.pointerId.
- : A number, defaulting to
width- : A number, defaulting to
1, that sets the value of the instance's PointerEvent.width.
- : A number, defaulting to
height- : A number, defaulting to
1, that sets the value of the instance's PointerEvent.height.
- : A number, defaulting to
pressure- : A number, defaulting to
0, that sets the value of the instance's PointerEvent.pressure.
- : A number, defaulting to
tangentialPressure- : A number, defaulting to
0, that sets the value of the instance's PointerEvent.tangentialPressure.
- : A number, defaulting to
altitudeAngle- : A number that sets the value of the instance's PointerEvent.altitudeAngle.
azimuthAngle- : A number that sets the value of the instance's PointerEvent.azimuthAngle.
tiltX- : A number that sets the value of the instance's PointerEvent.tiltX.
tiltY- : A number that sets the value of the instance's PointerEvent.tiltY.
twist- : A number, defaulting to
0, that sets the value of the instance's PointerEvent.twist.
- : A number, defaulting to
pointerType- : A string, defaulting to
""that sets the value of the instance's PointerEvent.pointerType.
- : A string, defaulting to
isPrimary- : A boolean value, defaulting to
falsethat sets the value of the instance's PointerEvent.isPrimary.
- : A boolean value, defaulting to
- : An object that, in addition of the properties defined in MouseEvent/MouseEvent, can have the following properties:
Return value
A new PointerEvent object.
Examples
const moveEvent = new PointerEvent("pointermove");
const downEvent = new PointerEvent("pointerdown", {
pointerId: 1,
bubbles: true,
cancelable: true,
pointerType: "touch",
width: 100,
height: 100,
isPrimary: true,
});
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
