このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
DeviceOrientationEvent
Baseline
2023
*
Newly available
Since September 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
* Some parts of this feature may have varying levels of support.
安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。
DeviceOrientationEvent は端末方向イベントのインターフェイスで、ウェブ開発者にウェブページを実行する端末の物理的な方向からの情報を提供します。
コンストラクター
DeviceOrientationEvent.DeviceOrientationEvent()-
新しい
DeviceOrientationEventを作成します。
インスタンスプロパティ
DeviceOrientationEvent.absolute読取専用-
論理値で、端末が絶対に方向データを提供するかどうかを示します。
DeviceOrientationEvent.alpha読取専用-
数値で、端末の Z 軸の回転量を表し、 0 (含む)から 360 (含まない)までの範囲の値で表します。
DeviceOrientationEvent.beta読取専用-
数値で、端末の X 軸の回転量を表し、 -180 (含む)から 180 (含まない)までの範囲の値で表します。これは端末の前後方向の動きを表します。
DeviceOrientationEvent.gamma読取専用-
数値で、端末の Z 軸の回転量を表し、 -90 (含む)から 90 (含まない)までの範囲の値で表します。これは端末の左右方向の動きを表します。
DeviceOrientationEvent.webkitCompassHeading非標準 読取専用-
数値で、ワールドシステムの Z 軸を中心とした端末の動きと北の方向との差を表し、 0 から 360 の範囲の値で度数で表します。
DeviceOrientationEvent.webkitCompassAccuracy非標準 読取専用-
コンパスの精度で、偏差が正の値または負の値を意味しています。通常は 10 です。
例
window.addEventListener("deviceorientation", (event) => {
console.log(`${event.alpha} : ${event.beta} : ${event.gamma}`);
});
仕様書
| Specification |
|---|
| Device Orientation and Motion> # deviceorientation> |
ブラウザーの互換性
Loading...