Moved orientationMap block

This commit is contained in:
Grant Benvenuti 2014-09-03 11:33:52 +10:00
parent e2983442cc
commit ad5a2134e8

View File

@ -1,5 +1,14 @@
var exec = require('cordova/exec'), var exec = require('cordova/exec'),
screenOrientation = {}; screenOrientation = {},
orientationMap = {
'portrait': [0,180],
'portrait-primary': [0],
'portrait-secondary': [180],
'landscape': [-90,90],
'landscape-primary': [-90],
'landscape-secondary': [90],
'default': [-90,90,0]
};
screenOrientation.setOrientation = function(orientation) { screenOrientation.setOrientation = function(orientation) {
exec(null, null, "YoikScreenOrientation", "screenOrientation", ['set', orientation]); exec(null, null, "YoikScreenOrientation", "screenOrientation", ['set', orientation]);
@ -10,16 +19,6 @@ module.exports = screenOrientation;
// ios orientation callback/hook // ios orientation callback/hook
window.shouldRotateToOrientation = function(orientation) { window.shouldRotateToOrientation = function(orientation) {
var currOrientation = cordova.plugins.screenorientation.currOrientation, var currOrientation = cordova.plugins.screenorientation.currOrientation,
orientationMap = {
'portrait': [0,180],
'portrait-primary': [0],
'portrait-secondary': [180],
'landscape': [-90,90],
'landscape-primary': [-90],
'landscape-secondary': [90],
'default': [-90,90,0]
},
map = orientationMap[currOrientation] || orientationMap['default']; map = orientationMap[currOrientation] || orientationMap['default'];
return map.indexOf(orientation) >= 0; return map.indexOf(orientation) >= 0;
}; };