{"name":"screenfull","version":"6.0.2","description":"Simple wrapper for cross-browser usage of the JavaScript Fullscreen API, which lets you bring the page or any element into fullscreen.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/screenfull.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":"^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && tsd"},"keywords":["browser","fullscreen"],"devDependencies":{"tsd":"^0.18.0","xo":"^0.45.0"},"xo":{"envs":["node","browser"]},"types":"./index.d.ts","gitHead":"560d9458f1e94742b51000b42407ce2eb67820cb","bugs":{"url":"https://github.com/sindresorhus/screenfull/issues"},"homepage":"https://github.com/sindresorhus/screenfull#readme","_id":"screenfull@6.0.2","_nodeVersion":"14.19.2","_npmVersion":"8.3.2","dist":{"integrity":"sha512-AQdy8s4WhNvUZ6P8F6PB21tSPIYKniic+Ogx0AacBMjKP1GUHN2E9URxQHtCusiwxudnCKkdy4GrHXPPJSkCCw==","shasum":"3dbe4b8c4f8f49fb8e33caa8f69d0bca730ab238","tarball":"http://registry-npm.ywwl.com/screenfull/download/screenfull-6.0.2.tgz","fileCount":5,"unpackedSize":17802,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGvd6Eb3vfkGQVOgS8Op8yh65pzBBBR5X6NHHo0XJpjOAiAWt+O9QgzARJP55e1Mv5inYRmD41wIqvBhswquM/lrtw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJirzNJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrgcA//T9QLN8G6HXsSTwl7vMiYw3fhy6Wo681YsXYk/9RrWxw/VIFB\r\n3HTKTEXRz9TNLFRvLF7+MmiLC3Ozy76AfRR+RvaXHOSCVVFfGXp8KN3tGycN\r\nKBGScqo7qZZz9qcG3tMB6TRvv1xk/keKwWRVEzoJfJGSFbj8aEKxqHcEIf5I\r\nI6F69lSUdFsyc+ffAmqJQex3aqX0WdcYA/pMv4WRttW6ABDdHKfP9o4Hcyg9\r\nud++/KBldPPJ644tlJoyIMzfckZeWrpwBvs8UgPxz63jB4b3N+PLd4RpXWyG\r\nU2x7l/S+lMVsCJsdcwjSN8Jch6Xh8OJ0DZTooqa8qfczcVFnUPN6icoASEzT\r\nzdemLcYRmECCPXT/e47smznpLEBkwtngr5DNyHAvw6Fao92kTdshmi0nK8Lk\r\nn9DpDJEWcHEZI9a1XOh7+LN0SChe5K59POkEjyJ742SeGpT8VyRJ6hoQqlHr\r\npIZTmmvmhxdEeAfuPB1A/YteGzm63pu6jz8T3j3e6UOu9Gg/nU3Q5H3tpoUv\r\nlFCQbrpqPClIFb9Rpmvqch8B8tlyx5te1eLUnTNoPogOU0ONGgWOg6mNi8qi\r\nUNpUt7U7AD7WP7Rhslqca7G44V+dBXq6dHq9ygb8m/F+tYto8gsLcYbwmHJc\r\npXoyC19jYN4+GJ3+blB5achwCoQINiilRKA=\r\n=OFXT\r\n-----END PGP SIGNATURE-----\r\n","size":5097,"noattachment":false,"key":"/screenfull/-/screenfull-6.0.2.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/screenfull_6.0.2_1655649096937_0.3284192943423696"},"_hasShrinkwrap":false,"readme":"# screenfull\n\n> Simple wrapper for cross-browser usage of the JavaScript [Fullscreen API](https://developer.mozilla.org/en/DOM/Using_full-screen_mode), which lets you bring the page or any element into fullscreen. Smoothens out the browser implementation differences, so you don't have to.\n\n**This package is ESM. Please [familiarize](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) yourself with that that implies.**\\\nIf you cannot use ESM or need to support older browsers without using transpilation, use version 5.2.0.\n\n**[Not supported on iPhone](#support)**\n\n**This package is feature complete. No new features will be accepted.**\n\n#### [Demo](https://sindresorhus.com/screenfull)\n\n## Install\n\nOnly 0.7 kB gzipped.\n\n```sh\nnpm install screenfull\n```\n\nAlso available on [cdnjs](https://cdnjs.com/libraries/screenfull.js/5.1.0) *(older version)*.\n\n## Why?\n\n### Screenfull\n\n```js\nimport screenfull from 'screenfull';\n\nif (screenfull.isEnabled) {\n\tscreenfull.request();\n}\n```\n\n### Vanilla JavaScript\n\n```js\ndocument.fullscreenEnabled =\n\tdocument.fullscreenEnabled ||\n\tdocument.mozFullScreenEnabled ||\n\tdocument.documentElement.webkitRequestFullScreen;\n\nfunction requestFullscreen(element) {\n\tif (element.requestFullscreen) {\n\t\telement.requestFullscreen();\n\t} else if (element.mozRequestFullScreen) {\n\t\telement.mozRequestFullScreen();\n\t} else if (element.webkitRequestFullScreen) {\n\t\telement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);\n\t}\n}\n\nif (document.fullscreenEnabled) {\n\trequestFullscreen(document.documentElement);\n}\n\n// This is not even entirely comprehensive. There's more.\n```\n\n## Support\n\n[Supported browsers](https://caniuse.com/#feat=fullscreen)\n\n**Note:** Safari is supported on desktop and iPad, but not on iPhone. This is a limitation in the browser, not in Screenfull.\n\n## Documentation\n\n### Examples\n\n#### Fullscreen the page\n\n```js\nimport screenfull from 'screenfull';\n\ndocument.getElementById('button').addEventListener('click', () => {\n\tif (screenfull.isEnabled) {\n\t\tscreenfull.request();\n\t} else {\n\t\t// Ignore or do something else\n\t}\n});\n```\n\n#### Fullscreen an element\n\n```js\nimport screenfull from 'screenfull';\n\nconst element = document.getElementById('target');\n\ndocument.getElementById('button').addEventListener('click', () => {\n\tif (screenfull.isEnabled) {\n\t\tscreenfull.request(element);\n\t}\n});\n```\n\n#### Hide navigation user-interface on mobile devices\n\n```js\nimport screenfull from 'screenfull';\n\nconst element = document.getElementById('target');\n\ndocument.getElementById('button').addEventListener('click', () => {\n\tif (screenfull.isEnabled) {\n\t\tscreenfull.request(element, {navigationUI: 'hide'});\n\t}\n});\n```\n\n#### Fullscreen an element with jQuery\n\n```js\nimport screenfull from 'screenfull';\n\nconst element = $('#target')[0]; // Get DOM element from jQuery collection\n\n$('#button').on('click', () => {\n\tif (screenfull.isEnabled) {\n\t\tscreenfull.request(element);\n\t}\n});\n```\n\n#### Toggle fullscreen on a image with jQuery\n\n```js\nimport screenfull from 'screenfull';\n\n$('img').on('click', event => {\n\tif (screenfull.isEnabled) {\n\t\tscreenfull.toggle(event.target);\n\t}\n});\n```\n\n#### Detect fullscreen change\n\n```js\nimport screenfull from 'screenfull';\n\nif (screenfull.isEnabled) {\n\tscreenfull.on('change', () => {\n\t\tconsole.log('Am I fullscreen?', screenfull.isFullscreen ? 'Yes' : 'No');\n\t});\n}\n```\n\nRemove listeners with:\n\n```js\nimport screenfull from 'screenfull';\n\nscreenfull.off('change', callback);\n```\n\n#### Detect fullscreen error\n\n```js\nimport screenfull from 'screenfull';\n\nif (screenfull.isEnabled) {\n\tscreenfull.on('error', event => {\n\t\tconsole.error('Failed to enable fullscreen', event);\n\t});\n}\n```\n\nSee the [demo](https://sindresorhus.com/screenfull) for more examples, and view the source.\n\n#### Fullscreen an element with Angular.js\n\nYou can use the [Angular.js binding](https://github.com/hrajchert/angular-screenfull) to do something like:\n\n```html\n<div ngsf-fullscreen>\n\t<p>This is a fullscreen element</p>\n\t<button ngsf-toggle-fullscreen>Toggle fullscreen</button>\n</div>\n```\n\n#### Fullscreen the page with Angular 2\n\n```ts\nimport {Directive, HostListener} from '@angular/core';\nimport screenfull from 'screenfull';\n\n@Directive({\n\tselector: '[toggleFullscreen]'\n})\nexport class ToggleFullscreenDirective {\n\t@HostListener('click') onClick() {\n\t\tif (screenfull.isEnabled) {\n\t\t\tscreenfull.toggle();\n\t\t}\n\t}\n}\n```\n\n```html\n<button toggleFullscreen>Toggle fullscreen<button>\n```\n\n### API\n\n#### .request(element, options?)\n\nMake an element fullscreen.\n\nAccepts a DOM element and [`FullscreenOptions`](https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions).\n\nThe default element is `<html>`. If called with another element than the currently active, it will switch to that if it's a descendant.\n\nIf your page is inside an `<iframe>` you will need to add a `allowfullscreen` attribute (+ `webkitallowfullscreen` and `mozallowfullscreen`).\n\nKeep in mind that the browser will only enter fullscreen when initiated by user events like click, touch, key.\n\nReturns a promise that resolves after the element enters fullscreen.\n\n#### .exit()\n\nBrings you out of fullscreen.\n\nReturns a promise that resolves after the element exits fullscreen.\n\n#### .toggle(element, options?)\n\nRequests fullscreen if not active, otherwise exits.\n\nAccepts a DOM element and [`FullscreenOptions`](https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions).\n\nReturns a promise that resolves after the element enters/exits fullscreen.\n\n#### .on(event, function)\n\nEvents: `'change' | 'error'`\n\nAdd a listener for when the browser switches in and out of fullscreen or when there is an error.\n\n#### .off(event, function)\n\nRemove a previously registered event listener.\n\n#### .onchange(function)\n\nAlias for `.on('change', function)`\n\n#### .onerror(function)\n\nAlias for `.on('error', function)`\n\n#### .isFullscreen\n\nReturns a boolean whether fullscreen is active.\n\n#### .element\n\nReturns the element currently in fullscreen, otherwise `undefined`.\n\n#### .isEnabled\n\nReturns a boolean whether you are allowed to enter fullscreen. If your page is inside an `<iframe>` you will need to add a `allowfullscreen` attribute (+ `webkitallowfullscreen` and `mozallowfullscreen`).\n\n#### .raw\n\nExposes the raw properties (prefixed if needed) used internally: `requestFullscreen`, `exitFullscreen`, `fullscreenElement`, `fullscreenEnabled`, `fullscreenchange`, `fullscreenerror`\n\n## FAQ\n\n### How can I navigate to a new page when fullscreen?\n\nThat's not supported by browsers for security reasons. There is, however, a dirty workaround. Create a seamless iframe that fills the screen and navigate to the page in that instead.\n\n```js\nimport screenfull from 'screenfull';\n\ndocument.querySelector('#new-page-button').addEventListener(() => {\n\tconst iframe = document.createElement('iframe')\n\n\tiframe.setAttribute('id', 'external-iframe');\n\tiframe.setAttribute('src', 'https://new-page-website.com');\n\tiframe.setAttribute('frameborder', 'no');\n\tiframe.style.position = 'absolute';\n\tiframe.style.top = '0';\n\tiframe.style.right = '0';\n\tiframe.style.bottom = '0';\n\tiframe.style.left = '0';\n\tiframe.style.width = '100%';\n\tiframe.style.height = '100%';\n\n\tdocument.body.prepend(iframe);\n\tdocument.body.style.overflow = 'hidden';\n});\n```\n\n## Resources\n\n- [Using the Fullscreen API in web browsers](https://hacks.mozilla.org/2012/01/using-the-fullscreen-api-in-web-browsers/)\n- [MDN - Fullscreen API](https://developer.mozilla.org/en/DOM/Using_full-screen_mode)\n- [W3C Fullscreen spec](https://fullscreen.spec.whatwg.org/)\n- [Building an amazing fullscreen mobile experience](https://developers.google.com/web/fundamentals/native-hardware/fullscreen/)\n","publish_time":1655649097099,"_cnpm_publish_time":1655649097099,"dist-tags":{"latest":"6.0.2"}}