Skip to content

Instantly share code, notes, and snippets.

@mildfuzz
Last active October 22, 2015 13:10
Show Gist options
  • Select an option

  • Save mildfuzz/5a5fc8f6a89824663d6a to your computer and use it in GitHub Desktop.

Select an option

Save mildfuzz/5a5fc8f6a89824663d6a to your computer and use it in GitHub Desktop.
Shim for adding window.orientation to desktop environments. Only does 0 or 90, not -90
(function(win) {
if ('orientation' in win) return;
if ('matchMedia' in win) {
var mtch = win.matchMedia('(orientation: portrait)');
win.orientation = mtch.matches ? 0 : 90;
mtch.addListener(function(m) {
win.orientation = m.matches ? 0 : 90;
});
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment