From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- .../api/window/deviceorientation_event/index.html | 171 +++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 files/ru/web/api/window/deviceorientation_event/index.html (limited to 'files/ru/web/api/window/deviceorientation_event/index.html') diff --git a/files/ru/web/api/window/deviceorientation_event/index.html b/files/ru/web/api/window/deviceorientation_event/index.html new file mode 100644 index 0000000000..0d264588d7 --- /dev/null +++ b/files/ru/web/api/window/deviceorientation_event/index.html @@ -0,0 +1,171 @@ +--- +title: deviceorientation +slug: Web/API/Window/deviceorientation_event +tags: + - Имитация смены положения + - Определение ориентации + - Ориентация + - Сенсоры +translation_of: Web/API/Window/deviceorientation_event +--- +

Событие deviceorientation срабатывает, когда с сенсоров ориентации поступают новые данные о текущем положении устройства внутри Земной системы координат. Эти данные собираются с помощью мангитометра устройства. Более детальное объяснение дано в Ориентация и объяснение данных движения.

+ +

Общая информация

+ +
+
Спецификация
+
Событие DeviceOrientation
+
Определение
+
DeviceOrientationEvent
+
Всплывает
+
Нет
+
Отменяемо
+
Нет
+
Целевой элемент
+
По умолчанию (window)
+
Действие по умолчанию 
+
 
+
Нет
+
+ +

Свойства

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescription
target {{readonlyInline}}{{domxref("EventTarget")}}The event target (the topmost target in the DOM tree).
type {{readonlyInline}}{{domxref("DOMString")}}The type of event.
bubbles {{readonlyInline}}{{jsxref("Boolean")}}Whether the event normally bubbles or not
cancelable {{readonlyInline}}{{jsxref("Boolean")}}Whether the event is cancellable or not?
alpha {{readonlyInline}}double (float)The current orientation of the device around the Z axis; that is, how far the device is rotated around a line perpendicular to the device.
beta {{readonlyInline}}double (float)The current orientation of the device around the X axis; that is, how far the device is tipped forward or backward.
gamma {{readonlyInline}}double (float)The current orientation of the device around the Y axis; that is, how far the device is turned left or right.
absolute {{readonlyInline}}{{jsxref("boolean")}}This value is true if the orientation is provided as a difference between the device coordinate frame and the Earth coordinate frame; if the device can't detect the Earth coordinate frame, this value is false.
+ +

Пример

+ +
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) {
+    // Сделайте что-нибудь необычное здесь
+};
+
+ +

Совместимость с браузерами

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
СвойствоChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Базовая поддержка7.03.6[1]{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
СвойствоAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Базовая поддержка3.03.6[1]{{CompatNo}}124.2
+
+ +

[1] Firefox 3.6, 4, и 5 поддерживают mozOrientation вместо стандартного события DeviceOrientation.

+ +

Похожие события

+ + + +

Смотрите также

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