DeviceMotionEvent
DeviceMotionEvent
インターフェイスは、ウェブ開発者に端末の位置と方向の変化のスピードに関する情報を提供します。
警告: 現在、Firefox と Chrome は同じ方法で座標を処理しません。これらを使用する際は、注意してください。
コンストラクター
DeviceMotionEvent()
(en-US)-
新しい
DeviceMotionEvent
を生成します。
プロパティ
DeviceMotionEvent.acceleration
(en-US) 読取専用-
3 つの軸 X、Y、Z 上の端末の加速度を与えるオブジェクトです。加速度は m/s² で表されます。
DeviceMotionEvent.accelerationIncludingGravity
(en-US) 読取専用-
X、Y、Z 上の端末の加速度を重力度込みで与えるオブジェクトです。加速度は m/s² で表されます。
DeviceMotionEvent.rotationRate
(en-US) 読取専用-
3 つの方向軸アルファ、ベータ、ガンマ上の端末の向きの変化率を与えるオブジェクトです。回転速度は 1 秒あたりの度数で表されます。
DeviceMotionEvent.interval
(en-US) 読取専用-
端末からデータを取得する間隔(ミリ秒)を表す数値です。
例
window.addEventListener('devicemotion', (event) => {
console.log(`${event.acceleration.x} m/s2`);
});
仕様書
Specification |
---|
DeviceOrientation Event Specification # devicemotion |
ブラウザーの互換性
BCD tables only load in the browser