diff --git a/README.md b/README.md index 2110622..6a9a197 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/www/screenorientation.js b/www/screenorientation.js index eb5df68..64c682b 100644 --- a/www/screenorientation.js +++ b/www/screenorientation.js @@ -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';