Merge pull request #64 from elitan/master

README events example added and orientation naming bug in orientationChange()
This commit is contained in:
Grant Benvenuti 2015-08-10 09:33:36 +10:00
commit 1195b40612
2 changed files with 10 additions and 2 deletions

View File

@ -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).

View File

@ -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';