Fscreen - Fullscreen API
Demo website (demo code on the gh-pages
branch)
Vendor agnostic access to the Fullscreen API. Build with the Fullscreen API as intended without worrying about vendor prefixes.
$ npm install --save fscreen
import fscreen from 'fscreen';
fscreen.fullscreenEnabled === true / false;
fscreen.fullscreenElement === null / undefined / DOM Element;
fscreen.requestFullscreen(element);
fscreen.requestFullscreenFunction(element);
fscreen.exitFullscreen();
fscreen.onfullscreenchange = handler;
fscreen.addEventListener('fullscreenchange', handler, options);
fscreen.removeEventListener('fullscreenchange', handler, options);
fscreen.onfullscreenerror = handler;
fscreen.addEventListener('fullscreenerror', handler, options);
fscreen.removeEventListener('fullscreenerror', handler, options);
fscreen.fullscreenPseudoClass;
Usage
Use it just like the spec API.
if (fscreen.fullscreenEnabled) {
fscreen.addEventListener('fullscreenchange', handler, false);
fscreen.requestFullscreen(element);
}
function handler() {
if (fscreen.fullscreenElement !== null) {
console.log('Entered fullscreen mode');
} else {
console.log('Exited fullscreen mode');
}
}