PointerEvent()

PointerEvent() コンストラクターは、新しい信頼できない合成 PointerEvent オブジェクトのインスタンスを作成します。

構文

new PointerEvent(type)
new PointerEvent(type, options)

引数

type

文字列で、イベントの名前を表します(PointerEvent のイベントの種類を参照)。

options 省略可

オブジェクトで、MouseEvent() で定義されているプロパティに加え、以下のプロパティを設定することができます。

pointerId

数値で、既定値は 0 であり、インスタンスの PointerEvent.pointerId の値を設定します。

width

数値で、既定値は 1 であり、インスタンスの PointerEvent.width の値を設定します。

height

数値で、既定値は 1 であり、インスタンスの PointerEvent.height の値を設定します。

pressure

数値で、既定値は 0 であり、インスタンスの PointerEvent.pressure の値を設定します。

tangentialPressure

数値で、既定値は 0 であり、インスタンスの PointerEvent.tangentialPressure の値を設定します。

tiltX

数値で、既定値は 0 であり、インスタンスの PointerEvent.tiltX の値を設定します。

tiltY

数値で、既定値は 0 であり、インスタンスの PointerEvent.tiltY の値を設定します。

twist

数値で、既定値は 0 であり、インスタンスの PointerEvent.twist の値を設定します。

pointerType

文字列で、既定値は "" であり、インスタンスの PointerEvent.pointerType の値を設定します。

isPrimary

論理値で、既定値は false であり、インスタンスの PointerEvent.isPrimary の値を設定します。

返値

新しい PointerEvent オブジェクトです。

const moveEvent = new PointerEvent("pointermove");

const downEvent = new PointerEvent("pointerdown",
   {pointerId: 1,
    bubbles: true,
    cancelable: true,
    pointerType: "touch",
    width: 100,
    height: 100,
    isPrimary: true
   });

仕様書

Specification
Pointer Events
# dom-pointerevent-constructor

ブラウザーの互換性

BCD tables only load in the browser