From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/deviceorientationevent/index.html | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 files/zh-cn/web/api/deviceorientationevent/index.html (limited to 'files/zh-cn/web/api/deviceorientationevent/index.html') diff --git a/files/zh-cn/web/api/deviceorientationevent/index.html b/files/zh-cn/web/api/deviceorientationevent/index.html new file mode 100644 index 0000000000..a65efefa94 --- /dev/null +++ b/files/zh-cn/web/api/deviceorientationevent/index.html @@ -0,0 +1,119 @@ +--- +title: DeviceOrientationEvent +slug: Web/API/DeviceOrientationEvent +translation_of: Web/API/DeviceOrientationEvent +--- +

{{apiref("Device Orientation Events")}}{{SeeCompatTable}}

+ +

DeviceOrientationEvent提供给网页开发者当设备(指手机,平板等移动设备)在浏览页面时物理旋转的信息。

+ +
+

警告: 当前,火狐浏览器和谷歌浏览器并未能用同一种方式实现,在使用请注意。(见后文) 

+
+ +

属性

+ +
+
{{domxref("DeviceOrientationEvent.absolute")}} {{readonlyinline}}
+
用来说明设备是提供的旋转数据是否是绝对定位的布尔值。
+
{{domxref("DeviceOrientationEvent.alpha")}} {{readonlyinline}}
+
一个表示设备绕z轴旋转的角度(范围在0-360之间)的数字
+
 
+
{{domxref("DeviceOrientationEvent.beta")}} {{readonlyinline}}
+
一个表示设备绕x轴旋转(范围在-180到180之间)的数字,从前到后的方向为正方向。
+
{{domxref("DeviceOrientationEvent.gamma")}} {{readonlyinline}}
+
一个表示设备绕y轴旋转(范围在-90到90之间)的数字,从左向右为正方向。
+
+ +

例子

+ +
window.addEventListener('deviceorientation', function(event) {
+  console.log(event.alpha + ' : ' + event.beta + ' : ' + event.gamma);
+});
+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态草案
{{SpecName('Device Orientation')}}{{Spec2('Device Orientation')}}Initial specification.
+ +

浏览器支持

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support7.0 [1]6 [2]{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
Basic support3.0{{CompatVersionUnknown}} [1]6 [2]{{CompatNo}}{{CompatNo}}4.2{{CompatVersionUnknown}} [1]
+
+ +

[1] 在版本50之前Chrome为该事件提供绝对的值而非相对的值。开发者仍需使用绝对的值,当使用{{domxref("ondeviceorientationabsolute")}} 事件时.

+ +

[2] 火狐3.6, 4, and 5支持mozOrientation 而非标准的 DeviceOrientationEvent

+ +

参考

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