Re: [manifest] orientation member

On Fri, Nov 29, 2013 at 7:41 AM, Marcos Caceres <marcos@marcosc.com> wrote:
> Option 1: Provide a list of orientation sets in the manifest. The user agent uses the first one with a matching media query. The order in which the orientations are listed by a developer does not imply a preference for setting the orientation - it is always left up to the user agent to pick the best orientation given, for example, how the user is holding the device. In the example below, no orientation is given for widths of 721px or above, so the default is used: allowing all orientations supported by the device.
>
> {
>     "orientations": [{
>         "media": "max-width: 320px",
>         "supported": ["portrait-primary", "landscape"]
>     }, {
>         "media": "max-width: 720px",
>         "supported": ["landscape"]
>     }]
> }

My impression has been that the vast majority of apps only need a
single orientation that is independent of media-query results. If
that's the case, then I think the above is too complicated. I.e. if
that is the common case, then we should support:

"orientation": ["landscape"],

or maybe even

"orientation": "landscape",

That could then scale to something as complex as what you have above
if really needed, which may or may not need to happen in the initial
version of the manifest spec.

One thing to keep in mind here is that applications that want complex
rules for orientation always have the option of not setting an
orientation in the manifest and instead using the JS API to do so.

The main benefit of the manifest is that it enables the UA to start
the application in the correct orientation right away, rather than
having to rotate the UI a fraction of a second after the app has been
started.

> Option 2: The second proposal is to remove orientation from the manifest and use CSS @viewport instead. This would mean:
>
> <head>
>     <style>
>         /*set it by default to portrait primary for small screens */
>         @media (max-width: 320px) {
>             @viewport {
>                 orientation: portrait-primary, landscape;
>             }
>         }
>         /*Tablet, switch to landscape only*/
>         @media (max-width: 720px) {
>             @viewport {
>                 orientation: landscape;
>             }
>         }
>
>         /* similarly on screens with a width of 721px or more, all orientations are allowed */
>     </style>
> </head>

As I understand it, the main use case for putting orientation in the
manifest is to enable the UA to launch the app in the correct
orientation from the get-go. It seems very hard for an implementation
to do that with this solution. You would have to inspect the cached
HTML and CSS to figure out what the initial orientation will be. If
there is any HTML/CSS cached. If it's loaded from the server or a
service worker you're completely out of luck.

So I think using CSS should be possible, but it doesn't solve the same
use case as putting something in the manifest.

> Problem with using @viewport at the moment is that the specification is progressing a bit  slowly and no one has implemented the "orientation" descriptor. It also lacks definitions for "-primary" and "-secondary" contraints, which are important for various applications, and doesn't currently allow providing multiple allowed orientations - hopefully the CSS Device Adaption spec can align with the Screen Orientation spec.

Yes. This is something that should be fixed irregardless of what the
manifest spec does.

/ Jonas

Received on Tuesday, 3 December 2013 04:49:17 UTC