Read more

screenfull.js: Simple wrapper for cross-browser usage of the JavaScript Fullscreen API

Arne Hartherz
April 30, 2018Software engineer at makandra GmbH

Using the JS fullscreen API is painful because all browers use different methods and events Show archive.org snapshot and you need to use lots of boilerplate code to make your application work in all browsers.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

The "screenfull" library wraps that for you, including events.

Examples

The linked GitHub repo contains some information. You basically use the library like this:

// Make an element go fullscreen
screenfull.request(element)

// Leave fullscreen
screenfull.exit()

// Detect if something is currently fullscreen
screenfull.isFullscreen

// Register event when going fullscreen
screenfull.on('change', functionCallback)    

// Get element that is currently fullscreening
screenfull.element

// De-register event
screenfull.off('change', functionCallback)

Note that no jQuery is required even though on and off may look like jQuery.

Posted by Arne Hartherz to makandra dev (2018-04-30 08:45)