このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

PointerEvent: PointerEvent() コンストラクター

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2020年7月⁩.

* Some parts of this feature may have varying levels of support.

>

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

構文

js
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 オブジェクトです。

js
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>

ブラウザーの互換性