【问题标题】:How to solve a problem with devicemotion script?如何解决 devicemotion 脚本的问题?
【发布时间】:2018-09-01 02:02:12
【问题描述】:

我不确定这是否适合提问,但我的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】:

    我的 webapp 也遇到了同样的问题。我看到 Chromium 62 上的加速度计存在问题,但似乎已在 v.63 中修复。

    但是,我这边的 chrome Android 上的“devicemotion”事件也不再有效(但在 iOS 上可以完美运行)。

    【讨论】:

      猜你喜欢
      • 2016-04-28
      • 2017-04-29
      • 1970-01-01
      • 1970-01-01
      • 2020-09-28
      • 2022-01-16
      • 2021-09-06
      • 2021-03-25
      • 1970-01-01
      相关资源
      最近更新 更多