Skip to content

Instantly share code, notes, and snippets.

@n1ckfg
Last active April 6, 2019 15:50
Show Gist options
  • Select an option

  • Save n1ckfg/d8d1de678a8a70ed96c2efed442f0bce to your computer and use it in GitHub Desktop.

Select an option

Save n1ckfg/d8d1de678a8a70ed96c2efed442f0bce to your computer and use it in GitHub Desktop.
function detectMobile() {
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) {
return true;
} else {
return false;
}
}
function detectPortrait() {
if (Math.abs(window.orientation) === 90) {
return false;
} else {
return true;
}
}
function detectMobilePortrait() {
if (detectMobile() && detectPortrait()) {
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment