Skip to content

Instantly share code, notes, and snippets.

@hoyangtsai
Last active April 11, 2020 10:13
Show Gist options
  • Save hoyangtsai/af692e124ea7faaf1157ca38c4f242b3 to your computer and use it in GitHub Desktop.
Save hoyangtsai/af692e124ea7faaf1157ca38c4f242b3 to your computer and use it in GitHub Desktop.
full screen class
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