Created
January 24, 2020 16:31
-
-
Save nicksspirit/9235730a5e8974837c3ec491b8008bc2 to your computer and use it in GitHub Desktop.
Javascript function that uses the Full Screen API to display an element in fullscreen.
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
| goFullScreen() { | |
| const fullScreenPrefixes = [ | |
| 'requestFullscreen', | |
| 'webkitRequestFullscreen', | |
| 'mozRequestFullScreen', | |
| 'msRequestFullscreen' | |
| ] | |
| // HTMLElement is the DOM element you want to make full screen | |
| const prefixedFn = fullScreenPrefixes.find( | |
| prefixedFn => HTMLElement[prefixedFn] !== undefined | |
| ) | |
| if (!prefixedFn) alert('Full Screen API is not supported in your browser') | |
| HTMLElement[prefixedFn]() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment