Select Page
View Categories

Screen Orientation

< 1 min read

Cordova plugin to set/lock the screen orientation in a common way.

For more info, please see the Screen Orientation plugin docs.

GitHub Source Code: https://github.com/apache/cordova-plugin-screen-orientation


Requires Cordova plugin: 
cordova-plugin-screen-orientation


Supported Platforms #

  • Android
  • iOS
  • Windows

Usage #


// get current
console.log(this.screenOrientation.type); // logs the current orientation, example: 'landscape'

// set to landscape
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);

// allow user rotate
this.screenOrientation.unlock();

// detect orientation changes
this.screenOrientation.onChange().subscribe(
   () => {
       console.log("Orientation Changed");
   }
);