Force landscape until switched back to portrait

So, I have a view where the user will be holding the phone in portrait, and I want to force the new view that pops in after they tap to be in landcape, but I want them to be able to go to a portrait view once the move the phone to landscape and back to portrait.

I can easily force the landscape view with…


but if I add…


…it never goes into landscape because it is detecting an orientation change and unlocking.

I thought what would happen is that after forcing the landscape view, the user would turn the phone to landscape, which would fire the onChange and unlock it, then when they turn the phone back to portrait view, it would go to portrait view.

So, now I only seem to be able to lock it in landscape or have the normal functionality which changes based on the device detecting the orientation.

How can I lock it to landscape just on the initial load and then let it switch back to detecting the normal device orientation?


"The type read-only property of the ScreenOrientation interface returns the document’s current orientation type, one of “portrait-primary”, “portrait-secondary”, “landscape-primary”, or “landscape-secondary”.


type = ScreenOrientation.type"
– from Mozilla.

You can get the type on change and lock it or not