简体   繁体   中英

Ignore device orientation on mobile

I have a Vue js component that triggers a method every time the orientation of the device changes to landscape. I have used window.addEventListener("orientationchange", functionName, false); to trigger the method.

This works perfectly fine on mobile when the device orientation is set to auto-rotate, but it doesn't when the orientation is set to portrait.

Is there any way to overwrite the portrait mode and detect when the device is rotating in order to trigger the method?

Setting the app to fullscreen mode and then calling window.screen.orientation.lock("any"); did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM