Skip to content

Instantly share code, notes, and snippets.

@tzookb
Created March 19, 2019 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzookb/2f6ff49609d1f825c5267095bdba6531 to your computer and use it in GitHub Desktop.
Save tzookb/2f6ff49609d1f825c5267095bdba6531 to your computer and use it in GitHub Desktop.
toggle full screen
const _toggleFullScreen = function _toggleFullScreen() {
if (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement) {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else {
if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else {
if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}
} else {
const _element = document.documentElement;
if (_element.requestFullscreen) {
_element.requestFullscreen();
} else {
if (_element.mozRequestFullScreen) {
_element.mozRequestFullScreen();
} else {
if (_element.webkitRequestFullscreen) {
_element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment