请问各位一下关于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.getElementByIdtip; var a= document.getElementByIda; 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…

发表评论

电子邮件地址不会被公开。 必填项已用*标注