You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by to...@apache.org on 2016/05/23 13:42:34 UTC
[36/50] cordova-plugin-screen-orientation git commit: Add more
readability
Add more readability
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/commit/479c32b6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/tree/479c32b6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/diff/479c32b6
Branch: refs/heads/master
Commit: 479c32b67cd0dc820412cad3a0eaf77b2e8ba69c
Parents: bbde995
Author: Moritz <m0...@gmail.com>
Authored: Tue Dec 8 18:14:57 2015 +0100
Committer: Moritz <m0...@gmail.com>
Committed: Tue Dec 8 18:14:57 2015 +0100
----------------------------------------------------------------------
README.md | 72 ++++++++++++++++++++++++++++++++--------------------------
1 file changed, 40 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/479c32b6/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 510d8bd..10dcf7c 100644
--- a/README.md
+++ b/README.md
@@ -2,73 +2,81 @@
Cordova plugin to set/lock the screen orientation in a common way for iOS, Android, WP8 and Blackberry 10. This plugin is based on an early version of [Screen Orientation API](http://www.w3.org/TR/screen-orientation/) so the api does not currently match the current spec.
-The plugin adds the following to the screen object:
+The plugin adds the following to the screen object (`window.screen`):
-__lockOrientation(ORIENTATION_STRING)__
-lock the device orientation
+```js
+// lock the device orientation
+.lockOrientation('portrait')
-__unlockOrientation()__
-unlock the orientation
+// unlock the orientation
+.unlockOrientation()
-__orientation__
-current orientation (ORIENTATION_STRING)
+// current orientation
+.orientation
+```
## Install
-cordova < 4
+_cordova < 4_
+```bash
cordova plugin add net.yoik.cordova.plugins.screenorientation
+```
+_cordova > 4_
-cordova > 4
-
+```bash
cordova plugin add cordova-plugin-screen-orientation
+```
## Supported Orientations
-__portrait-primary__
-The orientation is in the primary portrait mode.
+#### portrait-primary
+> The orientation is in the primary portrait mode.
-__portrait-secondary__
-The orientation is in the secondary portrait mode.
+#### portrait-secondary
+> The orientation is in the secondary portrait mode.
-__landscape-primary__
-The orientation is in the primary landscape mode.
+#### landscape-primary
+> The orientation is in the primary landscape mode.
-__landscape-secondary__
-The orientation is in the secondary landscape mode.
+#### landscape-secondary
+> The orientation is in the secondary landscape mode.
-__portrait__
-The orientation is either portrait-primary or portrait-secondary (sensor).
+#### portrait
+> The orientation is either portrait-primary or portrait-secondary (sensor).
-__landscape__
-The orientation is either landscape-primary or landscape-secondary (sensor).
+#### landscape
+> The orientation is either landscape-primary or landscape-secondary (sensor).
## Usage
- // set to either landscape
- screen.lockOrientation('landscape');
+```js
+// set to either landscape
+screen.lockOrientation('landscape');
- // allow user rotate
- screen.unlockOrientation();
+// allow user rotate
+screen.unlockOrientation();
- // access current orientation
- console.log('Orientation is ' + screen.orientation);
+// access current orientation
+console.log('Orientation is ' + screen.orientation);
+```
## 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.
-
For this plugin to follow the full API events should be fired on the screen object.
iOS and BB10 do not currently support events on the _screen_ object so custom event
handling will need to be added (Suggestions welcome!).
### Example usage
- window.addEventListener("orientationchange", function(){
- console.log('Orientation changed to ' + screen.orientation);
- });
+```js
+window.addEventListener("orientationchange", function(){
+ console.log(screen.orientation); // e.g. portrait
+});
+```
## Android Notes
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org