mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2025-05-04 17:32:12 +08:00
Merge pull request #64 from elitan/master
README events example added and orientation naming bug in orientationChange()
This commit is contained in:
commit
1195b40612
@ -64,6 +64,12 @@ For this plugin to follow the full API events should be fired on the screen obje
|
||||
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);
|
||||
});
|
||||
|
||||
## Android Notes
|
||||
|
||||
The __screen.orientation__ property will not update when the phone is [rotated 180 degrees](http://www.quirksmode.org/dom/events/orientationchange.html).
|
||||
|
@ -56,11 +56,13 @@ function addScreenOrientationApi(obj) {
|
||||
return;
|
||||
}
|
||||
screenOrientation.currOrientation = orientation;
|
||||
screen.orientation = screenOrientation.currOrientation;
|
||||
screenOrientation.setOrientation(orientation);
|
||||
};
|
||||
|
||||
obj.unlockOrientation = function() {
|
||||
screenOrientation.currOrientation = 'unlocked';
|
||||
screen.orientation = screenOrientation.currOrientation;
|
||||
screenOrientation.setOrientation('unlocked');
|
||||
};
|
||||
}
|
||||
@ -76,13 +78,13 @@ function orientationChange() {
|
||||
orientation = 'portrait-primary';
|
||||
break;
|
||||
case 90:
|
||||
orientation = 'landscape-secondary';
|
||||
orientation = 'landscape-primary';
|
||||
break;
|
||||
case 180:
|
||||
orientation = 'portrait-secondary';
|
||||
break;
|
||||
case -90:
|
||||
orientation = 'landscape-primary';
|
||||
orientation = 'landscape-secondary';
|
||||
break;
|
||||
default:
|
||||
orientation = 'unknown';
|
||||
|
Loading…
x
Reference in New Issue
Block a user