1.2.0 • Published 5 years ago

fscreen v1.2.0

Weekly downloads
79,174
License
MIT
Repository
github
Last release
5 years ago

Fscreen - Fullscreen API

npm

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;
// boolean to tell if fullscreen mode is supported
// replacement for: document.fullscreenEnabled
// mapped to: document.vendorMappedFullscreenEnabled

fscreen.fullscreenElement === null / undefined / DOM Element;
// null if not in fullscreen mode, or the DOM element that's in fullscreen mode
// (if fullscreen is not supported by the device it will be undefined)
// replacement for: document.fullscreenElement
// mapped to: document.vendorMappedFullsceenElement
// note that fscreen.fullscreenElement uses a getter to retrieve the element
// each time the property is accessed.


fscreen.requestFullscreen(element);
// replacement for: element.requestFullscreen()
// mapped to: element.vendorMappedRequestFullscreen()

fscreen.requestFullscreenFunction(element);
// replacement for: element.requestFullscreen - without calling the function
// mapped to: element.vendorMappedRequestFullscreen

fscreen.exitFullscreen();
// replacement for: document.exitFullscreen()
// mapped to: document.vendorMappedExitFullscreen()
// note that fscreen.exitFullscreen is mapped to
// document.vendorMappedExitFullscreen - without calling the function


fscreen.onfullscreenchange = handler;
// replacement for: document.onfullscreenchange = handler
// mapped to: document.vendorMappedOnfullscreenchange = handler

fscreen.addEventListener('fullscreenchange', handler, options);
// replacement for: document.addEventListener('fullscreenchange', handler, options)
// mapped to: document.addEventListener('vendorMappedFullscreenchange', handler, options)

fscreen.removeEventListener('fullscreenchange', handler, options);
// replacement for: document.removeEventListener('fullscreenchange', handler, options)
// mapped to: document.removeEventListener('vendorMappedFullscreenchange', handler, options)


fscreen.onfullscreenerror = handler;
// replacement for: document.onfullscreenerror = handler
// mapped to: document.vendorMappedOnfullscreenerror = handler

fscreen.addEventListener('fullscreenerror', handler, options);
// replacement for: document.addEventListener('fullscreenerror', handler, options)
// mapped to: document.addEventListener('vendorMappedFullscreenerror', handler, options)

fscreen.removeEventListener('fullscreenerror', handler, options);
// replacement for: document.removeEventListener('fullscreenerror', handler, options)
// mapped to: document.removeEventListener('vendorMappedFullscreenerror', handler, options)


fscreen.fullscreenPseudoClass;
// returns: the vendorMapped fullscreen Pseudo Class
// i.e. :fullscreen, :-webkit-full-screen, :-moz-full-screen, :-ms-fullscreen
// Can be used to find any elements that are fullscreen using the vendorMapped Pseudo Class 
// e.g. document.querySelectorAll(fscreen.fullscreenPseudoClass).forEach(...);

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');
 }
}
@oyvinmar-forks/shared-uigatsby-theme-evelangatsby-theme-sanity-evelangrandbois@telus-uds/components-allium-web@ardoq/shared-ui@everything-registry/sub-chunk-1707flare-dispatchtabletop-game-workshopwix-rich-content-fullscreenwebampstorymodevue-guacamole-clientkyle-tableshelper-componentsinsert-popup-formreact-web-media-playerreact-web-simple-widgets@wix/ricos@vime/core@vidstack/elements@viplayer/core@yt-project/yt-widgets@telus-uds/components-webauto-full-screenarma-twiloflexlib-boards@prysm-software/visionjs@acceleratxr/react-shared@blendmedia/fuse@byondrnd/byondxr-web-visualizer-ui@christianprescott/assembly@bdelab/roam-apps@bdelab/roam-fluency@bdelab/roar-letter@bdelab/roar-multichoice@bdelab/roar-readaloud@bdelab/roar-swr@bdelab/roar-tasks@bdelab/roav-crowding@bdelab/roav-mep@bdelab/roav-ranclowdr-video-frontendcore-taskscwrc-writer-basebrowser-ui-stateassembly-apptwilio-video-app-react-gaompytwilio-video-app-tszhu-jiang-yi-yuan-bigscreenzhu-jiang-yi-yuan-mobilemitosheet-frontendroar-repackagereact-full-screenreact-mobile-fullscreenprogressive-carouselsehatcloudreact-expression-treereact-native-styled-simple-widgetsnb-basereact-xrplayer@cwrc/leafwriter@cylynx/motif@deathbeds/jupyterlab-literallycanvas@demos-europe/demosplan-ui@demos-europe/demosplan-utils@cs-chatbots/webchat-ui@designbycosmic/vime-core@exezt-/webamp@exezt-/webamp-custom@fengbeans/antd-waffle@goodgamestudios/cxf-fullscreen@interlude-games/its-a-wonderful-world@glints/video-rooms-client@gamepark/react-game@straw-hat/react-fullscreen@mcfed/components@miat/cafe@levante-framework/core-tasks@tds/core-video@next-book/interface@sentrei/video@macrostrat/column-components@mando212/better-player
1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago