fullscreen

fullscreen polyfill api that presents an event emitter

npm install fullscreen
5 downloads in the last day
38 downloads in the last week
130 downloads in the last month

fullscreen

polyfill for requestFullscreen


var fullscreen = require('fullscreen')
  , el = document.getElementById('element')
  , fs

fs = fullscreen(el)

el.addEventListener('click', function() {
  fs.request()
})

document.body.onkeydown = function() {
  fs.release()
}

fs.on('attain', function() {
  // attained fullscreen
})

fs.on('release', function() {
  // released fullscreen
})

fs.on('error', function() {
  // fullscreen request failed, or
  // fullscreen isn't supported
})

API

require('fullscreen').available() -> bool

return a boolean yes/no for whether fullscreen api is supported.

fullscreen(element) -> fs event emitter

return a fullscreen event emitter object. if fullscreen is not available, on the next turn of the event loop it'll emit 'error'.

fs.request() -> undefined

issue a request for fullscreen. if it's accepted, it emits 'attain', otherwise 'error' for denial.

fs.release() -> undefined

release the current fullscreen element. if the fullscreen is released, it emits 'release'.

fs.target() -> HTMLElement?

returns the current fullscreen target, if any.

License

MIT

npm loves you