The `fullscreen-api-polyfill` package provides a robust polyfill for the W3C Fullscreen API, abstracting away various vendor-prefixed implementations like `mozRequestFullScreen` and `webkitRequestFullScreen`. It enables developers to use the standard `element.requestFullscreen()`, `document.exitFullscreen()`, and access properties such as `document.fullscreenEnabled` and `document.fullscreenElement`, as well as event listeners for `fullscreenchange` and `fullscreenerror`, without needing to write extensive browser-specific conditional logic. The current stable version is `1.1.2`. As a polyfill for a web standard that has largely matured, its release cadence is likely low, focusing on maintaining compatibility and addressing any remaining browser inconsistencies rather than introducing new features. Its primary differentiation is the simplification of cross-browser fullscreen implementation down to a single, standard W3C syntax.
npm install fullscreen-api-polyfillVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the `fullscreen-api-polyfill` to enter and exit fullscreen mode, and listen for related events, ensuring cross-browser compatibility with the standard W3C API methods.
Before relying on fullscreen functionality, check `document.fullscreenEnabled` to ensure the browser and context support it.
Regularly update the `fullscreen-api-polyfill` package to its latest version to ensure compatibility with evolving browser implementations and W3C spec changes.
If targeting environments without native Promise support, include a Promise polyfill (e.g., `core-js` or `es6-promise`) before importing `fullscreen-api-polyfill` if you intend to use the Promise-based return values.
Always invoke `element.requestFullscreen()` or `document.exitFullscreen()` within a user interaction event listener, such as a `click` handler.
Ensure `import 'fullscreen-api-polyfill';` is at the very top of your application's entry point. Verify that the browser being used has at least a prefixed fullscreen API implementation.
Always check `document.fullscreenElement` before calling `document.exitFullscreen()` to confirm an element is indeed in fullscreen mode.
Ensure `element.requestFullscreen()` is only called in response to a direct user interaction like a button click.
No dependency data recorded yet.