关于手机是横向还是纵向和旋转角度

监听旋转: window.addEventListener(‘deviceorientation’, rotateScene, false);

可以通过获取window.orientation的属性值来进行判断:

横向:Math.abs(window.orientation) == 90;

纵向:window.orientation == 0;

旋转角度:var theta = (Math.abs(window.orientation) == 90) ? e.beta : e.gamma;
              rotationY = 0 + (15 * (theta / -45)); 

执行旋转:$scene.css(‘transform’: ‘rotateY(‘ + rotationY + ‘deg)’);

posted @ 2012-07-25 11:01  华丽@低调  阅读(263)  评论(0编辑  收藏  举报