ons.orientation

Utility methods for orientation detection.

Methods Summary #

Signature Description
isPortrait() Returns whether the current screen orientation is portrait or not.
isLandscape() Returns whether the current screen orientation is landscape or not.
on(eventName, listener) Add an event listener.
once(eventName, listener) Add an event listener that's only triggered once.
off(eventName, [listener]) Remove an event listener. If the listener is not specified all listeners for the event type will be removed.

Events Summary #

Name Description
change Fired when the device orientation changes.

Methods

isPortrait(): Boolean #

Returns whether the current screen orientation is portrait or not.

Returns: Will be true if the current orientation is portrait mode.

isLandscape(): Boolean #

Returns whether the current screen orientation is landscape or not.

Returns: Will be true if the current orientation is landscape mode.

on(eventName, listener) #

Add an event listener.

Parameters
Name Type Description
eventName String Name of the event.
listener Function Function to execute when the event is triggered.

once(eventName, listener) #

Add an event listener that's only triggered once.

Parameters
Name Type Description
eventName String Name of the event.
listener Function Function to execute when the event is triggered.

off(eventName, [listener]) #

Remove an event listener. If the listener is not specified all listeners for the event type will be removed.

Parameters
Name Type Description
eventName String Name of the event.
listener Function Function to execute when the event is triggered.

Events

change #

Fired when the device orientation changes.

Parameters
Name Type Description
event Object Event object.
event.isPortrait Boolean Will be true if the current orientation is portrait mode.

Discussion #