Last active
April 11, 2020 10:13
-
-
Save hoyangtsai/af692e124ea7faaf1157ca38c4f242b3 to your computer and use it in GitHub Desktop.
full screen class
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
fullScreenClass() { | |
const w = window.innerWidth | |
|| document.documentElement.clientWidth | |
|| document.body.clientWidth; | |
const h = window.innerHeight | |
|| document.documentElement.clientHeight | |
|| document.body.clientHeight; | |
const ratio = +(h / w); | |
const ua = navigator.userAgent; | |
// exceed the screen ratio of 16:9 | |
if (ratio > 1.7777) { | |
if (/android/i.test(ua)) { | |
return 'android-fullscreen' | |
} else if (/iphone/i.test(ua)) { | |
return 'ios-fullscreen' | |
} else { | |
return 'fullscreen' | |
} | |
} else { | |
return ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment