Skip to content

Instantly share code, notes, and snippets.

@jameswragg
Created October 27, 2011 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameswragg/1319241 to your computer and use it in GitHub Desktop.
Save jameswragg/1319241 to your computer and use it in GitHub Desktop.
Orientationchange event oddities
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