请问各位一下关于orienter的问题

小弟想写一个使用重力感应移动图片的代码,使用orienter,如果直接改变图片的left值,没有效果,请问该如何修改代码?

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>orienter</title>
    <meta name="description" content=""/>
    <meta name="viewport" content="width=640, target-densitydpi=device-dpi, user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>

    <script type="text/javascript" src="../orienter.js"></script>

    <style>
        ul, li {
            list-style: none;
            line-height: 0px;
        }

        body, div, ul, li, img, p, a, h1, h2, h3 {
            margin: 0px;
            padding: 0px;
            border: 0px;
        }

        html, body {
            background: #000;
            color: #fff;
            font-family: "微软雅黑", "黑体", "宋体", Helvetica, Verdana, sans-serif;
            font-size: 10px;
        }
        #a{top: 50%;position:absolute;height: 40%;transition: 3s}
        #tip {
            font-size: 60px;
        }
    </style>

</head>

<body>
<img id="a" src="a.jpg"></p>
<p id="tip"></p>
<script>
    var o = new Orienter();
    var tip = document.getElementById('tip');
    var a= document.getElementById('a');
    o.orient = function (obj) {
        tip.innerHTML =
                'alpha:' + obj.a +
                '<br>' + 'beta:' + obj.b +
                '<br>' + 'gamma:' + obj.g +
                '<br>' + 'longitude:' + obj.lon +
                '<br>' + 'latitude:' + obj.lat +
                '<br>' + 'direction:' + obj.dir +
                '<br>' + 'left:'+ a.style.left;
    };
    o.init();
</script>

</body>
</html>

a为图片的id,orienter下载地址:https://github.com/shrekshrek...

阅读 3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题