Search code examples
screen-orientationfirefox-os

Firefoxos is there a simple way to make my app automatically and only landscape


I read this https://developer.mozilla.org/en-US/docs/Web/Apps/Manifest however it seems pretty unclear to me.

orientation

(Android & Firefox OS only, optional) An array that defines the orientations at which the application will stay locked, even if the device orientation changes. Each entry in the array can be one of portrait, landscape, portrait-primary, landscape-primary, portrait-secondary or landscape-secondary. The options containing -primary and -secondary lock the orientation in only one device orientation, even if the device orientation changes. The options without -primary and -secondary combine both rules of primary and secondary together. The options additionally suffixed with -secondary imply a 180 degree rotation from the options without the suffix. For instance, holding the phone upside down (but still in a manner where width is less than height), implies the portrait-secondary orientation. If this field has a valid value, the runtime will not change the orientation of the view rendering the application even if the device is turned. Example:

"orientation": ["portrait","landscape-secondary"]

What? So how do I make my app default in landscape mode, and lock in landscape mode no matter what?


Solution

  • Try using this manifest value "orientation": "landscape-primary"

    In script you can also try: screen.mozLockOrientation("landscape-primary");

    If you only use landscape, your app will display in landscape but can also rotate 180 degrees. Using landscape-primary will prevent this from happening.