手机陀螺仪

$(function(){
			window.addEventListener("deviceorientation", handleOrientation);

			function handleOrientation(event) {
			  var absolute = event.absolute;
			  var alpha    = event.alpha;
			  var beta     = event.beta;
			  var gamma    = event.gamma;

			  $('.box').html(gamma)
              if(gamma<-20 || gamma>20){
                return false;
              }
			  $('.bg').css({'margin-left':-gamma*10,'-webkit-transform':'rotateY('+gamma+'deg)'});

			}

		})

  

posted on 2016-06-14 18:39  什么嘉  阅读(138)  评论(0编辑  收藏  举报

导航