Screenfull.js - Simple cross browser wrapper for Fullscreen API
The Fullscreen API is fairly new with growing support but the implementation varies across browsers. Screenfull.js is a simple script from Sindre Sorhus to change that, changing:
document.fullscreenEnabled = document.fullscreenEnabled || document.mozFullScreenEnabled || document.documentElement.webkitRequestFullScreen;
function requestFullscreen( element ) {
if ( element.requestFullscreen ) {
element.requestFullscreen();
} else if ( element.mozRequestFullScreen ) {
element.mozRequestFullScreen();
} else if ( element.webkitRequestFullScreen ) {
element.webkitRequestFullScreen( Element.ALLOW_KEYBOARD_INPUT );
}
}
if ( document.fullscreenEnabled ) {
requestFullscreen( document.documentElement );
}
to
if ( screenfull ) screenfull.request();
The source is on GitHub.
Discussion
Sign in or Join to comment or subscribe