Skip to content

Instantly share code, notes, and snippets.

@trunkslamchest
Created July 19, 2020 17:38
Show Gist options
  • Save trunkslamchest/e18f5fea6d1bad2c53d86b5b29b401ac to your computer and use it in GitHub Desktop.
Save trunkslamchest/e18f5fea6d1bad2c53d86b5b29b401ac to your computer and use it in GitHub Desktop.
b24_6
document.addEventListener("DOMContentLoaded", initDetect)
function initDetect(){
window.addEventListener("resize", detectDevice)
detectDevice()
}
detectDevice = () => {
let detectObj = {
device: !!navigator.maxTouchPoints ? 'mobile' : 'computer',
orientation: !navigator.maxTouchPoints ? 'desktop' : !window.screen.orientation.angle ? 'portrait' : 'landscape'
}
console.log(detectObj)
return detectObj
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment