ons.orientation

Utility methods for orientation detection.

Methods Summary

Signature Description
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.
isPortrait() Returns whether the current screen orientation is portrait or not.
isLandscape() Returns whether the current screen orientation is landscape or not.

Events Summary

Name Description
change Fired when the device orientation changes.

Methods

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.

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.

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

Need Help?

If you have any questions, use our Community Forum or talk to us via Gitter chat. The Onsen UI team and your peers in the community will work together to help solve your issues.

For bug reports and feature requests use our GitHub Issues page.