From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/window/deviceorientation_event/index.html | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 files/ja/web/api/window/deviceorientation_event/index.html (limited to 'files/ja/web/api/window/deviceorientation_event/index.html') diff --git a/files/ja/web/api/window/deviceorientation_event/index.html b/files/ja/web/api/window/deviceorientation_event/index.html new file mode 100644 index 0000000000..7f54466091 --- /dev/null +++ b/files/ja/web/api/window/deviceorientation_event/index.html @@ -0,0 +1,86 @@ +--- +title: 'Window: deviceorientation イベント' +slug: Web/API/Window/deviceorientation_event +tags: + - Device Orientation API + - Sensors + - Window Event + - events +translation_of: Web/API/Window/deviceorientation_event +--- +

{{APIRef}}

+ +

deviceorientation イベントは、端末の現在の向きを地球座標フレームと比較した場合に、方角センサーから最新のデータが得られた場合に発生します。このデータは端末内部の磁力計から収集されます。詳細については、向きと動きのデータの説明を参照してください。

+ + + + + + + + + + + + + + + + + + + + +
バブリングいいえ
キャンセル不可
インターフェイス{{domxref("DeviceOrientationEvent")}}
イベントハンドラープロパティ{{domxref("window.ondeviceorientation")}}
+ +

+ +
if (window.DeviceOrientationEvent) {
+    window.addEventListener("deviceorientation", function(event) {
+        // alpha: rotation around z-axis
+        var rotateDegrees = event.alpha;
+        // gamma: left to right
+        var leftToRight = event.gamma;
+        // beta: front back motion
+        var frontToBack = event.beta;
+
+        handleOrientationEvent(frontToBack, leftToRight, rotateDegrees);
+    }, true);
+}
+
+var handleOrientationEvent = function(frontToBack, leftToRight, rotateDegrees) {
+    // do something amazing
+};
+
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態
{{SpecName("Device Orientation", "#deviceorientation", "DeviceOrientation event")}}{{Spec2("Device Orientation")}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Window.deviceorientation_event")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf