hiloteam / Hilo

A Cross-end HTML5 Game development solution
https://hiloteam.github.io/
MIT License
5.93k stars 863 forks source link

检测浏览器是否支持横屏的方法是否应该完善一下? #91

Closed xbufan closed 7 years ago

xbufan commented 7 years ago

检测浏览器是否支持横屏,window.orientation 已经不建议使用。并且在现代浏览器中,即使 'orientation' in window 返回false,window 实际上也可以绑定 orientationchange 事件。有一个实验性的特性,但是并没有被 Safari 支持。另外,参照这里'ondevicemotion' in window 在 Chrome/FF 下是可以正确检测的。 希望检测的方法能完善一下。

06wj commented 7 years ago

'orientation' in window || 'orientation' in window.screen 这样就可以了吧

ondevicemotion是检测手机方向的 和这个不一样