Created
October 28, 2011 08:56
-
-
Save mrbase/1321907 to your computer and use it in GitHub Desktop.
Triggers onorientationchange events.
This file contains hidden or 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
(function() { | |
if (window.orientation) { | |
window.onorientationchange = function() { | |
var orientation = 'portrait'; | |
if (window.orientation == 90 || window.orientation == -90) { | |
orientation = 'landscape'; | |
} | |
$('html').addClass(orientation); | |
$('body').trigger( | |
'orientationchange', // the trigger | |
orientation, // orientation of the document | |
window.orientation // angle in degrees | |
); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have not used the snippit for many years now, so I actually don't know if it still works.