WebAPI/ScreenOrientation: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with "== Proposed API == partial interface Screen { readonly attribute DOMString orientation; attribute Function onorientationchange; boolean lockOrientation(DO...")
 
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Proposed API ==
This API is now a Working Draft at W3C (WebApps WG) so for any documentation, please refer to the specification:<br>
https://dvcs.w3.org/hg/screen-orientation/raw-file/tip/Overview.html


  partial interface Screen {
[[Category:Web APIs]]
    readonly attribute DOMString orientation;
            attribute Function onorientationchange;
    boolean lockOrientation(DOMString orientation);
  }
 
 
The <code>Screen</code> object is a property of the Window object and has existed since DOM Level 0 (i.e. for a really long time). This API adds three new properties to the object.
 
The <code>orientation</code> attribute is either <code>"landscape-primary"</code>, <code>"landscape-secondary"</code>, <code>"portrait-primary"</code> or <code>"portrait-secondary"</code>. The reason for these values rather than "upsidedown" or something similar is that some devices are by default in landscape mode (desktop/tablets) and some devices (most mobile) are by default in portrait mode.
 
Whenever the device orientation changes, an <code>"orientationchange"</code> event is fired on the Screen object *before* the rotation happens.

Latest revision as of 23:56, 1 October 2014

This API is now a Working Draft at W3C (WebApps WG) so for any documentation, please refer to the specification:
https://dvcs.w3.org/hg/screen-orientation/raw-file/tip/Overview.html