Created
March 17, 2016 18:30
-
-
Save jonasantonelli/1a590374bff016cae6ea to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
Fullscreen Class | |
*/ | |
class Fullscreen { | |
constructor() { | |
document.cancelFullScreen = document.webkitCancelFullScreen || document.mozCancelFullScreen || document.cancelFullScreen; | |
document.body.requestFullScreen = document.body.webkitRequestFullScreen || document.body.mozRequestFullScreen || document.body.requestFullScreen; | |
document.addEventListener("fullscreenchange", () => { | |
document.onfullscreenchange.call(this); | |
}, false); | |
document.addEventListener("mozfullscreenchange", () => { | |
document.onfullscreenchange.call(this); | |
}, false); | |
document.addEventListener("webkitfullscreenchange", () => { | |
document.onfullscreenchange.call(this); | |
}, false); | |
document.addEventListener("msfullscreenchange", ()=> { | |
document.onfullscreenchange.call(this); | |
}, false); | |
} | |
isFullScreen() { | |
return !!(document.webkitIsFullScreen || document.mozFullScreen || document.isFullScreen); // if any defined and true | |
} | |
fullScreenElement() { | |
return document.webkitFullScreenElement || | |
document.webkitCurrentFullScreenElement || | |
document.mozFullScreenElement || | |
document.fullScreenElement; | |
} | |
} | |
export default Fullscreen; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment