如何解决devicemotion脚本的问题?

问题描述 投票:11回答:1

我不确定这是否是问的正确地方,但是我的devicemotion脚本有问题。

我有一些代码在页面加载时运行,以检查是否有陀螺仪可用。我通过以下方式执行此操作:

function check_user_hardware(){

    if (mobile_size <= 600) {
        hidden = true;
    }
    console.log("checking hardware");
    giro_timer = setTimeout(update_gyro_value, 30);
    window.addEventListener("devicemotion", function(event){
        console.log("device motion?");
        if(event.rotationRate.alpha || event.rotationRate.beta || event.rotationRate.gamma){
            calculate_rotation_mesh_pos(event.rotationRate.beta, event.rotationRate.gamma);
            if (!gyroscope) {
                gyroscope = true;
                console.log("gyroscope here");
                current_interaction_mode = 'gyroscope_option';
                set_user_ui_elements();
            }
        }else{
            followMouse = true;
            console.log("no gyroscope here");
            current_interaction_mode = 'followMouse_option';
            set_user_ui_elements();
            window.addEventListener('mousemove', get_user_mouse_pos);
        }
    });
}

这在几周前就很好了,但是现在不再起作用了。我在控制台中看到以下打印:

checking hardware

就这样。为什么我的devicemotion事件不触发?即使在使用基本SSL加密的网站上也无法正常工作,为什么?我需要某种特殊的SSL加密吗?这是怎么回事欢迎提出所有建议!如果需要更多信息,我将很乐意提供。您可以在此处查看有问题的网站:gravient.thomashoek.com

javascript ssl browser devicemotion
1个回答
0
投票

我在我的Web应用程序上遇到了同样的问题。我发现在Chromium 62上存在有关加速度计的问题,但似乎在v.63中已解决。

但是'devicemotion'事件在我这边的chrome Android上也不再起作用(但在iOS上却能正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.