Created
October 27, 2011 10:32
-
-
Save jameswragg/1319241 to your computer and use it in GitHub Desktop.
Orientationchange event oddities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var orientation = getOrientation(), | |
newOrientation; | |
Titanium.Gesture.addEventListener('orientationchange', function(e){ | |
if (e.orientation == Titanium.UI.PORTRAIT || e.orientation == Titanium.UI.UPSIDE_PORTRAIT){ | |
newOrientation = 'portrait'; | |
}else if(e.orientation == Titanium.UI.LANDSCAPE_LEFT || e.orientation == Titanium.UI.LANDSCAPE_RIGHT){ | |
newOrientation = 'landscape'; | |
} | |
if (newOrientation != orientation) { | |
// Every orientation change causes this to fire 5 times!? | |
Log.Info('Orientationchange. Was: ' + orientation + ', now: ' + newOrientation); | |
orientation = newOrientation; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment