TouchEvent: changedTouches プロパティ

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

changedTouches は読み取り専用プロパティで、 TouchList です。そのタッチ点(Touch オブジェクト)はイベントタイプによって以下のように異なります。

  • touchstart イベントでは、現在のイベントでアクティブになったタッチ点のリストです。
  • touchmove イベントでは、前回のイベント以降に変更されたタッチ点のリストです。
  • touchend イベントでは、これはタッチ面から除去されたタッチ点のリストです(つまり、タッチ面に触れなくなった指に対応するタッチ点の集合)。

TouchListTouch オブジェクトには、このタッチイベントに寄与したすべてのタッチ点が含まれています。

この例では、TouchEvent オブジェクトの TouchEvent.changedTouches プロパティを示します。 TouchEvent.changedTouches プロパティは TouchList オブジェクトで、イベントに貢献した各タッチ点の Touch オブジェクトを 1 つ格納します。

以下のコードでは、 touchmove イベントハンドラーが changedTouches リストを反復処理し、最後のイベント以降に変更された各タッチ点の識別子を出力しています。

js
someElement.addEventListener(
  "touchmove",
  (e) => {
    // 最後のイベント以降に変更されたタッチ点のリストを反復処理し、
    // 各タッチ点の識別子を出力
    for (let i = 0; i < e.changedTouches.length; i++) {
      console.log(
        `changedTouches[${i}].identifier = ${e.changedTouches[i].identifier}`,
      );
    }
  },
  false,
);

仕様書

Specification
Touch Events
# dom-touchevent-changedtouches

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
changedTouches

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Has more compatibility info.