On 27/05/13 14:12, pancake wrote: > On 05/27/13 04:24, Marco Chen wrote: >> Hi, >> >> You can refer to the link as below. Which is used to test orientation >> sensor on gaia app. >> https://github.com/mozilla-b2g/gaia/blob/master/test_apps/test-sensors/js/physical-events.js#L23 >> > > device orientation != orientation. The first requires a 3D compass > hardware to know alpha, beta and gamma angles, and the second one just > shows the user interface rotation orientation (landscape, portrait). > > The code i pasted before only seems to work fine on iOS, but there's a > workaround to get similar results using css media queries from javascript: > > https://jbkflex.wordpress.com/2013/05/23/orientationchange-does-not-work-in-mobile-firefox-for-androids-wtf/ > > > which results in the following code: > > window.matchMedia ("(orientation:portrait)").addListener (function (x) { > alert (x.matches?"portrait": "landscape"); > }); > > The problem i see here is that you can't identify the correct UI angle, > this is not a problem using the (standard?) way like mobile safari does, > which sets window.orientation value and this one can be 0, 90, -90, 180. > > I would like to see this api working on Firefox, doing css media hacks > from javascript shouldnt be the way..
This API isn't good because the orientation angle doesn't mean anything given that it depends on the device. Firefox Android and Firefox OS are implementing this API: http://dvcs.w3.org/hg/screen-orientation/raw-file/tip/Overview.html (It is moz-prefixed.) -- Mounir _______________________________________________ dev-b2g mailing list [email protected] https://lists.mozilla.org/listinfo/dev-b2g
