2

我正在制作一个交互式网络应用程序,它需要检查当前设备上是否存在陀螺仪。在加载所有其他 javascript 之前,我需要执行一次此检查。

我找到了以下有关如何执行操作的文章。

但是,当我尝试此代码时,请参阅下面的内容总是得到没有陀螺仪.. 在 iphone 和台式机以及笔记本电脑和平板电脑上。为什么会这样?这个问题有解决方案还是不可能?

看看我到目前为止尝试过的代码:

if (window.DeviceMotionEvent) {
    console.log("yes "+window.DeviceMotionEvent);
    gyroscope = true;
    followMouse = false;
    current_interaction_mode = 'gyroscope_option';
}else{
    console.log("no "+ window.DeviceMotionEvent);
    followMouse = true;
    gyroscope = false;
    current_interaction_mode = 'followMouse_option';
}

$(document).ready(function(){
    //all the other code to be executed...
});

如果有什么遗漏或不清楚,请告诉我:)
提前感谢所有帮助。

4

0 回答 0