cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject docs commit: Blog post for cordova-plugin-screen-orientation plugin
Date Wed, 26 Apr 2017 17:33:54 GMT
Repository: cordova-docs
Updated Branches:
  refs/heads/master 31ec6ad6a -> c05e91903

Blog post for cordova-plugin-screen-orientation plugin

 This closes #690


Branch: refs/heads/master
Commit: c05e91903375b513ce74f435a82cd6f9da694ce6
Parents: 31ec6ad
Author: maverickmishra <>
Authored: Thu Mar 30 11:18:36 2017 -0700
Committer: Shazron Abdullah <>
Committed: Wed Apr 26 10:32:46 2017 -0700

 .../     | 70 ++++++++++++++++++++
 1 file changed, 70 insertions(+)
diff --git a/www/_posts/ b/www/_posts/
new file mode 100644
index 0000000..07061ca
--- /dev/null
+++ b/www/_posts/
@@ -0,0 +1,70 @@
+layout: post
+    name: Vishal Mishra
+    url:
+title:  "Screen Orientation Plugin"
+categories: news
+tags: cordova screen orientation
+Originally posted at this [PhoneGap blog](
+## Cordova Screen Orientation Plugin
+The new version(2.0.0) of the cordova screen orientation plugin was released recently. The
purpose of the plugin is to set/lock the screen orientation in a common way for all the major
platforms. This new version conforms with the specifications mentioned in the [W3C Screen
Orientation API](, currently in open draft.
+The plugin incorporates these major updates:
+1. Locking/unlocking the screen orientation.
+2. Accessing the current screen orientation.
+3. Addition of 'onchange' event handler to the screen.orientation object.
+4. A Demo App.
+### Locking/unlocking the screen orientation
+The screen orientation can be locked to a particular orientation, say, for example, landscape,
using :
+screen.orientation.lock('landscape').then(function success() {
+    console.log("Successfully locked the orientation");
+}, function error(errMsg) {
+    console.log("Error locking the orientation :: " + errMsg);
+The code above sets the screen orientation device to any landscape mode
+( landscape-primary or landscape-secondary) depending upon the rotation.
+The screen.orientation.lock(OrientationLockType); method returns a promise.On successfully
setting the orientation, it resolves a promise. If the screen is not locked successfully,
the promise rejects with 'NotSupportedError' .
+The screen orientation can be unlocked by using:
+The code above makes the screen adapt to the default orientation of the device. The unlock
method does not return a promise.
+### Accessing the current screen orientation
+The current screen orientation can be accessed as :
+console.log('Orientation is' + screen.orientation.type);
+### Addition of 'onchange' attribute to the screen.orientation object
+An example usage of the 'onchange' event handler:
+screen.orientation.onchange = function(){
+ 	console.log(screen.orientation.type);
+The 'change' event can also be added to the screen.orientation object :
+screen.orientation.addEventListener('change', function(){
+ 	console.log(screen.orientation.type);
+### The Demo Application
+The demo application is included on the github repository. Once the plugin has been added
to it, the demo application allows the user to test the orientation types with the screen.orientation.lock()
method. The demo application is explained in detail [here](

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message