Re: Screen Orientation API Spec (from phrasing confusion)

On Sun, 23 Feb 2014, at 20:12, Bruno Racineux wrote:
> Unless I am missing, something my current issue with screen.orientation
> is
> that it does not actually specify which is the "natural" orientation
> right
> away, UNLESS the device is rotated once. Is this really by design?
> Ref. again: 
> http://msdn.microsoft.com/en-us/library/ie/dn433241(v=vs.85).aspx
> 
> That seems to defeat the "normal orientation" aspect of the spec and the
> usefulness of '-primary' and '-secondary' suffixes "for the initial
> state".

There is a bug on file to make the explanation a bit clearer:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24699

The relation between -primary and -secondary should be up to the UA. If
Microsoft wants to give specific angles, why not. As pointed in another
thread in this mailing list, I am planning to add an angle information
to the API.

> On Wed, Nov 6, 2013, at 11:17, Jonas Sicking wrote:
> > Last I looked the property was useless because window.orientation=0
> > meant different things on different devices. I.e. on some devices it
> > meant "landscape mode" and others it meant "portrait mode".
> 
> It's not completely useless because one can tell the initial orientation
> by other means. (either media queries or deduction from screen
> width/height)
> 
> As per Mounir, 0 indicates the natural orientation, which
> screen.orientation lacks as best illustrated by M. Gifford:
> http://www.matthewgifford.com/blog/2011/12/22/a-misconception-about-window-
> orientation/
> 
> Based on the above, the implied official specs of window.orientation is
> quite consistent with legacy implementations.

I recently landed a usage counter for window.orientation. It will take
some time to roll to Chrome Android stable but hopefully we will find
out if window.orientation is actually used a lot. If that's the case and
other UA want to implement it, we could incorporate that into this
specification. In any case, I would like to add this feature but not as
|window.orientation|.

> >So unless webcompat at some point requiring it, I don't see us adding it.
> 
> I think it should be, because the screen orientation API lack the
> 'natural' orientation, at the moment anyway. I was actually trying to
> somehow polyfill the [0,90,-90,180] of window.orientation with
> screen.orientation. But I cannot account for the 0 (normal orientation)
> due to the initial orientation value having two definitions. :\
> 
> And honestly with screen.orientation, I currently have to write 12 lines
> of code to deduct whether the device was turned left of right, from the
> initial state, as opposed to the more straight forward window.orientation
> for that particular goal.

Your use case will be taken care of, see this bug:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24698

> On Wed, 06 Nov 2013 11:27:08,Mounir Lamouri wrote:
> >Indeed, if I remember correctly, window.orientation=0 is the "natural"
> >orientation and then, the value is the angle between the current
> >orientation and the natural one in the range ] -180 ; 180 ].
> 
> Mounir, note that there is no -180 angle, as far as I know.
> 
> I think that -180 only applies to DeviceOrientation Events.

That's correct. That's why I wrote ] -180; 180 ] instead of [ -180; 180
] ;)

-- Mounir

Received on Thursday, 13 March 2014 18:00:18 UTC