Index

Module: OrientationManager

OrientationManager manages the orientation.

There're some cases we need to reset the orientation of the top window:

  • LockScreen is unlocked.
  • AttentionScreen is hidden.
  • AttentionScreen is closed.
  • TrustedUI is closed.
  • SleepMenu is hidden.

Any of them occurs would trigger OrientationManager to dispatch reset-orientation event and AppWindowManager would reset the orientation of the active window.

Change orientation flow

Members

private static _isOnRealDevice :Boolean

Record if we are on real device or not.

static defaultOrientation :String

Default orientation of this device, possible values are:

  • portrait-primary
  • landscape-primary

Methods

static fetchCurrentOrientation() → {String}

Get current orientation

Returns:
String

Current orientation, possible values: portrait-primary, portrait-secondary, landscape-primary, landscape-secondary.

static fetchDefaultOrientation()

Get the default orientation of the device when device booted.
This is a trick done by locking the orientation at first and
then get by screen.mozOrientation.


If we are not on a real device, we will guess the orientation by
the ratio of width and height of window.

static isDefaultPortrait() → {Boolean}

Test if our default orientation is portrait.

Returns:
Boolean

If our default orientation is portrait.

static isOnRealDevice() → {Boolean}

Test if we are on real device by checking the available width.

Returns:
Boolean

If we are on real device or not.

Events

reset-orientation

Fired when the orientation needs to be locked/unlocked again.