Skip to content

Instantly share code, notes, and snippets.

@mrbase
Created October 28, 2011 08:56
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 mrbase/1321907 to your computer and use it in GitHub Desktop.
Save mrbase/1321907 to your computer and use it in GitHub Desktop.
Triggers onorientationchange events.
(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
);
}
}
})();
@alex4buba
Copy link

I read that this is depracated ... Can I see somwhere a working html page example?

Thanks

@mrbase
Copy link
Author

mrbase commented May 28, 2020

I have not used the snippit for many years now, so I actually don't know if it still works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment