mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2025-02-23 16:42:50 +08:00
update README with latest api
This commit is contained in:
parent
288c2f8ef2
commit
fc2df8bec1
18
README.md
18
README.md
@ -78,7 +78,7 @@ screen.orientation.lock('landscape');
|
||||
screen.orientation.unlock();
|
||||
|
||||
// access current orientation
|
||||
console.log('Orientation is ' + screen.orientation);
|
||||
console.log('Orientation is ' + screen.orientation.type);
|
||||
```
|
||||
|
||||
## Events
|
||||
@ -91,10 +91,24 @@ For this version of the plugin use the window object if you require notification
|
||||
|
||||
```js
|
||||
window.addEventListener("orientationchange", function(){
|
||||
console.log(screen.orientation); // e.g. portrait
|
||||
console.log(screen.orientation.type); // e.g. portrait
|
||||
});
|
||||
```
|
||||
|
||||
The 'change' event listener has also been added to the screen.orientation object.
|
||||
|
||||
### Example usage
|
||||
|
||||
```js
|
||||
screen.orientation.addEventListener('change', function(){
|
||||
console.log(screen.orientation.type); // e.g. portrait
|
||||
});
|
||||
// OR
|
||||
|
||||
screen.orientation.onchange = function(){console.log(screen.orientation.type);
|
||||
};
|
||||
|
||||
```
|
||||
## Android Notes
|
||||
|
||||
The __screen.orientation__ property will not update when the phone is [rotated 180 degrees](http://www.quirksmode.org/dom/events/orientationchange.html).
|
||||
|
Loading…
Reference in New Issue
Block a user