All Projects → apache → Cordova Plugin Screen Orientation

apache / Cordova Plugin Screen Orientation

Licence: apache-2.0
Cordova Plugin Screen Orientation

Programming Languages

javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language
csharp
926 projects
cplusplus
227 projects

Projects that are alternatives of or similar to Cordova Plugin Screen Orientation

Cordova Plugin Device Motion
Apache Cordova Plugin device-motion
Stars: ✭ 58 (-67.96%)
Mutual labels:  library, mobile, cordova
Cordova Node Xcode
Apache cordova
Stars: ✭ 128 (-29.28%)
Mutual labels:  library, mobile, cordova
Cordova Cli
Apache Cordova CLI
Stars: ✭ 861 (+375.69%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Splashscreen
Apache Cordova Plugin splashscreen
Stars: ✭ 602 (+232.6%)
Mutual labels:  library, mobile, cordova
Cordova Browser
Apache Cordova
Stars: ✭ 142 (-21.55%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Wkwebview Engine
[DEPRECATED] Apache Cordova wkwebview engine plugin
Stars: ✭ 607 (+235.36%)
Mutual labels:  library, mobile, cordova
Cordova Mobile Spec
Apache Cordova mobile-spec
Stars: ✭ 57 (-68.51%)
Mutual labels:  library, mobile, cordova
Cordova Plugin File Transfer
Apache Cordova Plugin file-transfer
Stars: ✭ 537 (+196.69%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Globalization
Apache Cordova Plugin globalization
Stars: ✭ 131 (-27.62%)
Mutual labels:  library, mobile, cordova
Cordova Firefoxos
[DEPRECATED] Apache Cordova firefoxos
Stars: ✭ 41 (-77.35%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Test Framework
Apache Cordova
Stars: ✭ 66 (-63.54%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Vibration
Apache Cordova Plugin vibration
Stars: ✭ 109 (-39.78%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Geolocation
Apache Cordova Plugin geolocation
Stars: ✭ 584 (+222.65%)
Mutual labels:  library, mobile, cordova
Cordova Plugin File
Apache Cordova Plugin file
Stars: ✭ 664 (+266.85%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Statusbar
Apache Cordova
Stars: ✭ 581 (+220.99%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Camera
Apache Cordova Plugin camera
Stars: ✭ 879 (+385.64%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Whitelist
Apache Cordova plugin whitelist
Stars: ✭ 442 (+144.2%)
Mutual labels:  library, mobile, cordova
Cordova Weinre
Mirror of Apache Weinre
Stars: ✭ 506 (+179.56%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Inappbrowser
Apache Cordova Plugin inappbrowser
Stars: ✭ 994 (+449.17%)
Mutual labels:  library, mobile, cordova
Cordova App Harness
[DEPRECATED] Apache Cordova app harness
Stars: ✭ 49 (-72.93%)
Mutual labels:  library, mobile, cordova

title: Screen Orientation description: Set the screen orientation

AppVeyor Travis CI
Build status Build Status

Cordova Screen Orientation Plugin

Cordova plugin to set/lock the screen orientation in a common way for iOS, Android, and windows-uwp. This plugin is based on Screen Orientation API so the api matches the current spec.

The plugin adds the following to the screen object (window.screen):

// lock the device orientation
.orientation.lock('portrait')

// unlock the orientation
.orientation.unlock()

// current orientation
.orientation

Install

cordova plugin add cordova-plugin-screen-orientation

Supported Orientations

portrait-primary

The orientation is in the primary portrait mode.

portrait-secondary

The orientation is in the secondary portrait mode.

landscape-primary

The orientation is in the primary landscape mode.

landscape-secondary

The orientation is in the secondary landscape mode.

portrait

The orientation is either portrait-primary or portrait-secondary (sensor).

landscape

The orientation is either landscape-primary or landscape-secondary (sensor).

any

orientation is unlocked - all orientations are supported.

Usage

// set to either landscape
screen.orientation.lock('landscape');

// allow user rotate
screen.orientation.unlock();

// access current orientation
console.log('Orientation is ' + screen.orientation.type);

Events

Both android and iOS will fire the orientationchange event on the window object. For this version of the plugin use the window object if you require notification.

Example usage

window.addEventListener("orientationchange", function(){
    console.log(screen.orientation.type); // e.g. portrait
});

The 'change' event listener has also been added to the screen.orientation object.

Example usage

screen.orientation.addEventListener('change', function(){
    console.log(screen.orientation.type); // e.g. portrait
});
    // OR

screen.orientation.onchange = function(){console.log(screen.orientation.type);
};

Android Notes

The screen.orientation property will not update when the phone is rotated 180 degrees.

Windows UWP Notes

Windows store apps (windows-uwp) will only display orientation changes if the device has some sort of accelerometer. The internal state of the "orientation" will still be kept, but the actual screen won't rotate unless the device supports it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].