working version of screen orientation plugin adhering to w3c specs

This commit is contained in:
maverickmishra
2017-01-09 16:42:53 -08:00
parent 912b6b199b
commit 1f536ec80e
4 changed files with 127 additions and 107 deletions
+1 -1
View File
@@ -50,7 +50,7 @@
<button id="btnPortPrimary">Portrait - Primary</button>
<button id="btnLandPrimary">Landscape - Primary</button>
</div>
<button id="btnAny">Any</button>
<button id="btnAny">Unlock</button>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
+9 -18
View File
@@ -36,44 +36,35 @@ var app = {
onDeviceReady: function() {
app.receivedEvent('deviceready');
btnPortrait.addEventListener("click", function() {
// alert('Orientation is ' + screen.orientation);
screen.lockOrientation('portrait').then(function(obj) {
screen.orientation.lock('portrait').then(function(obj) {
console.log(obj);
}).catch(function(obj) {
}, function(obj) {
console.log(obj);
});
});
btnLandscape.addEventListener("click", function() {
// alert('Orientation is ' + screen.orientation);
screen.lockOrientation('landscape').then(function(obj) {
screen.orientation.lock('landscape').then(function(obj) {
console.log(obj);
}).catch(function(obj) {
}, function(obj) {
console.log(obj);
});
});
btnPortPrimary.addEventListener("click", function() {
// alert('Orientation is ' + screen.orientation);
screen.lockOrientation('portrait-primary').then(function(obj) {
screen.orientation.lock('portrait-primary').then(function(obj) {
console.log(obj);
}).catch(function(obj) {
}, function(obj) {
console.log(obj);
});
});
btnLandPrimary.addEventListener("click", function() {
// alert('Orientation is ' + screen.orientation);
screen.lockOrientation('landscape-primary').then(function(obj) {
screen.orientation.lock('landscape-primary').then(function(obj) {
console.log(obj);
}).catch(function(obj) {
}, function(obj) {
console.log(obj);
});
});
btnAny.addEventListener("click", function() {
// alert('Orientation is ' + screen.orientation);
screen.lockOrientation('any').then(function(obj) {
console.log(obj);
}).catch(function(obj) {
console.log(obj);
});
screen.orientation.unlock();
});