详解html5如何获取手机陀螺仪角度信息的示例代码


当前第2页 返回上一页

gamma:扭转(自转)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

<html>

<head>

    <title>DeviceOrientationEvent</title>

    <meta charset="UTF-8" />

    <meta name="viewport"

    content="width=device-width,

    initial-scale=1.0,

    minimum-scale=1.0,

    maximum-scale=1.0,

    user-scalable=no">

    <script src="js/common/jquery.min.js"></script>

    <script src="js/common/eventutil.js"></script>

</head>

<body>

    <p id="arrow"></p>

</body>

</html>

 

 

<script>

    try {

        var text = "";

        window.addEventListener("deviceorientation", orientationHandler, false);

        function orientationHandler(event) {

            text = ""

            var arrow = document.getElementById("arrow");

            text += "左右旋转:rotate alpha{" + Math.round(event.alpha) + "deg)<p>";

            text += "前后旋转:rotate beta{" + Math.round(event.beta) + "deg)<p>";

            text += "扭转设备:rotate gamma{" + Math.round(event.gamma) + "deg)<p>";

            arrow.innerHTML = text;

        }

    }

    catch (e) {

        $("#arrow").html(e.message)

    }

</script>

以上就是详解html5如何获取手机陀螺仪角度信息的示例代码的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

妙味课堂HTML5视频资料分享

详细介绍HTML5技术在风电、光伏等新能源领域的应用(图)

HTML5编程实战之三-图片文本(txt)拖拽预览实现代码

HTML5调用摄像头的示例代码分享

HTML5桌面通知之notification api详解

HTML5前景怎么样

HTML5文件异步上传功能的实现

HTML5文件上传插件遇到的技术问题

HTML5标准学习-文档结构详解

HTML5如何正确设置视频的宽高

更多相关阅读请进入《HTML5》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...