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.

News Films

Our little film studio focuses on telling developer-centric stories that need to be seen.

Beyond Code: Season 3 / GopherCon 2015

 
0:00 / 0:00