我正在为Firefox编写需要检测动作的浏览器扩展程序。在浏览解决方案的过程中,我遇到了很多使用事件监听器检测动作的代码片段,如下所示:
var onDeviceMotion = function (eventData) {
console.log(eventData.acceleration);
console.log(eventData.accelerationIncludingGravity);
console.log(eventData.rotationRate);
console.log(eventData.interval);
}
window.addEventListener('devicemotion', onDeviceMotion, false);
我想知道是否有办法在不使用上述代码中的事件监听器的情况下检测设备运动。