mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2025-02-23 16:42:50 +08:00
changed orientation spec and modified Readme
This commit is contained in:
parent
86a9c8131d
commit
c00a7c4b85
32
README.md
32
README.md
@ -67,6 +67,9 @@ cordova plugin add cordova-plugin-screen-orientation
|
||||
#### landscape
|
||||
> The orientation is either landscape-primary or landscape-secondary (sensor).
|
||||
|
||||
#### any
|
||||
> orientation is landscape-primary or landscape-secondary (sensor).
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
@ -101,38 +104,15 @@ window.addEventListener("orientationchange", function(){
|
||||
|
||||
The __screen.orientation__ property will not update when the phone is [rotated 180 degrees](http://www.quirksmode.org/dom/events/orientationchange.html).
|
||||
|
||||
## iOS Notes
|
||||
|
||||
The iOS version is a combination of the cordova JS callback _window.shouldRotateToOrientation_ and the workaround to recheck the orientation as implemented in https://github.com/Adlotto/cordova-plugin-recheck-screen-orientation.
|
||||
|
||||
__If you have a custom implementation of the _window.shouldRotateToOrientation_ it will have to be removed for the plugin to function as expected.__
|
||||
|
||||
#### iOS6
|
||||
|
||||
There has been a few cases where the rotation does not change the width of the viewport
|
||||
|
||||
Issue [#1](https://github.com/gbenvenuti/cordova-plugin-screen-orientation/issues/1) @dokterbob
|
||||
|
||||
>It seems to be related to having width=device-width, height=device-height in the meta viewport (which is part of the boilerplate phonegap/cordova app). It can be solved by updating the viewport with width=device-height, height=device-width or simply removing width and height altogether.
|
||||
|
||||
#### iOS8
|
||||
|
||||
Versions prior to 1.2.0 will cause an application crash in iOS8 due to a change in presentViewController timing.
|
||||
|
||||
## BB10 Notes
|
||||
|
||||
Wraps the com.blackberry.app plugin functions, auto installed as a dependancy.
|
||||
|
||||
## WP8 Notes
|
||||
|
||||
Windows phone does not support specification or primary and secondary orientations. If called with a specific orientation the plugin will just apply the landscape or portait orientation.
|
||||
|
||||
## W8.1 Notes
|
||||
|
||||
Windows 8.1 Applicaitons (runtime/metro applications) 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.
|
||||
|
||||
# Changelog
|
||||
|
||||
## 2.0
|
||||
* Common javascript for iOS, Android and Windows.
|
||||
|
||||
## 1.4.2
|
||||
* [#101](https://github.com/gbenvenuti/cordova-plugin-screen-orientation/pull/101) make iOS rotate as needed when lockOrientation is called
|
||||
|
||||
|
@ -33,13 +33,12 @@ import android.util.Log;
|
||||
|
||||
public class CDVOrientation extends CordovaPlugin {
|
||||
|
||||
private static final String TAG = "YoikScreenOrientation";
|
||||
|
||||
/**
|
||||
* Screen Orientation Constants
|
||||
*/
|
||||
|
||||
private static final String UNLOCKED = "unlocked";
|
||||
private static final String ANY = "any";
|
||||
private static final String PORTRAIT_PRIMARY = "portrait-primary";
|
||||
private static final String PORTRAIT_SECONDARY = "portrait-secondary";
|
||||
private static final String LANDSCAPE_PRIMARY = "landscape-primary";
|
||||
@ -74,7 +73,7 @@ public class CDVOrientation extends CordovaPlugin {
|
||||
|
||||
Activity activity = cordova.getActivity();
|
||||
|
||||
if (orientation.equals(UNLOCKED)) {
|
||||
if (orientation.equals(ANY)) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
} else if (orientation.equals(LANDSCAPE_PRIMARY)) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
|
@ -36,7 +36,7 @@
|
||||
];
|
||||
|
||||
screenOrientation.Orientations = Orientations;
|
||||
screenOrientation.currOrientation = 'natural';
|
||||
screenOrientation.currOrientation = 'any';
|
||||
var orientationMask = 0;
|
||||
screenOrientation.setOrientation = function(orientation) {
|
||||
if(orientation == 'portrait-primary'){
|
||||
@ -57,7 +57,7 @@
|
||||
else if(orientation == 'landscape'){
|
||||
orientationMask = 12;
|
||||
}
|
||||
else if(orientation == 'natural'){
|
||||
else if(orientation == 'any'){
|
||||
orientationMask = 15;
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@
|
||||
};
|
||||
|
||||
screenObject.unlockOrientation = function() {
|
||||
screenOrientation.currOrientation = screenObject.orientation = 'natural';
|
||||
screenOrientation.setOrientation('natural');
|
||||
screenOrientation.currOrientation = screenObject.orientation = 'any';
|
||||
screenOrientation.setOrientation('any');
|
||||
};
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@
|
||||
orientation = 'landscape-secondary';
|
||||
break;
|
||||
default:
|
||||
orientation = 'unknown';
|
||||
orientation = 'any';
|
||||
}
|
||||
|
||||
screen.orientation = orientation;
|
||||
|
Loading…
Reference in New Issue
Block a user