设备方向alpha不会在每个角度返回值

时间:2016-08-23 03:51:24

标签: javascript android-orientation device-orientation

某些设备在设备方向的变化alpha上不返回每个角度值。 代码如下:

window.addEventListener('deviceorientation', function(eventData) {
  // gamma is the left-to-right tilt in degrees, where right is positive
  var tiltLR = eventData.gamma;
  var absolute = eventData.absolute;
  document.getElementById("r4").innerHTML = absolute;
  // beta is the front-to-back tilt in degrees, where front is positive
  var tiltFB = eventData.beta;
  // alpha is the compass direction the device is facing in degrees
  var dir = eventData.alpha
    // call our orientation event handler
  deviceOrientationHandler(tiltLR, tiltFB, dir);
}, false);

eventData.absolute返回undefined的设备有alpha工作正常,但eventData.absolute返回true的设备有alpha不能正常工作(alpha返回{{1这只意味着不返回像0,180,360等每个角度。是否可以通过任何Javascript代码修复此问题?

0 个答案:

没有答案