我正在寻找一个jQuery插件或Javascript库,它使用G传感器检测设备的旋转程度,而不仅仅是方向。 我知道可以做到 – 检查https://wagerfield.github.io/parallax/ – 但我还没有找到这样的东西。
如果它创造了一种可以实时更新的全局,那就太棒了。
谢谢!
你可以使用jquery mobile lib orientationchange事件。
$(window).on("orientationchange",function(event){ var x = event.beta, // -180 to 180 y = event.gamma, // -90 to 90 z = event.alpha; // 0 to 360 });
没有jQuery:
window.addEventListener('orientationchange', function(event){ var x = event.beta, // -180 to 180 y = event.gamma, // -90 to 90 z = event.alpha; // 0 to 360 });
也尝试这个..
if (window.DeviceOrientationEvent) { window.addEventListener('deviceorientation', function(event){ }); }
以上就是jQuery教程分享使用jQuery检测移动设备旋转相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/jquerytutorial/532642.html