Re: Device Orientation: alternate representations and handling screen orientation changes

Hi,

Thank you Rich for bringing that subject. The interaction between the
Screen Orientation and the Device Orientation is interesting. In that
regard, I did some experiments a few months ago to find out whether the
Screen Orientation API should expose the screen orientation angle
compared to the native orientation angle. There are indeed some basic
use cases where it is required to know the screen orientation angle in
order to draw something on the screen based on Device Orientation data.
The most basic example for that would be a compass app. You can try this
at http://oldworld.fr/google/compass.html - it is using
window.orientation, a proprietary API to draw the compass correctly
(don't mind the dirty code, this is a quick hack).

However, I would not recommend UA to change the values of the Device
Orientation based on the screen orientation angle. I am planning to add
an angle information to the Screen Orientation API and at that point,
when the API will be available too, developers could use that
information if they want too. I think it would be more interesting for
the Web as a platform if we try to avoid "magic" manipulation of data.

Modifying Device Orientation values based on Screen Orientation angle
might not be trivial for some developers so the Device Orientation
specification could probably include some code snippet to help
developers do this. Alternatively, if this proves to be a big issue, the
Device Orientation could have an option to return values that are
already modified to include the screen orientation angle. I would prefer
to think of that solution as a last resort because introducing
auto-magic in the platform isn't a great thing generally speaking. Do
native platforms provide such API?

Cheers,
-- Mounir

Received on Monday, 31 March 2014 10:03:16 UTC