<!doctype html><html lang="zh"><head>
<meta charset="UTF-8">
<title>Document</title></head><body>
<p id="tip"></p>
<script>
window.addEventListener('deviceorientation', function (orientData) {
document.getElementById('tip').innerHTML = orientData.alpha;
}); </script></body></html>手機(jī)掃描二維碼查看效果,現(xiàn)在的效果是進(jìn)入頁(yè)面后晃動(dòng)手機(jī)會(huì)顯示手機(jī)X軸的角度信息,到達(dá)0度臨界值的時(shí)候,左右晃動(dòng)手機(jī)角度的變化規(guī)律是357,358,359,0,1,2,3以此類推的這種格式,有沒有辦法更改成到達(dá)0度的時(shí)候是-3,-2,-1,0,1,2,3,到達(dá)359的時(shí)候是357,358,359,360,361,362的這種格式呢?
JS檢測(cè)設(shè)備方向疑問
慕哥6287543
2018-10-17 10:09:12