{"name":"screenfull","version":"5.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.js.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"main":"dist/screenfull.js","engines":{"node":">=0.10.0"},"scripts":{"pretest":"grunt","test":"xo && tsd"},"keywords":["browser","fullscreen"],"devDependencies":{"grunt":"^1.0.4","grunt-contrib-concat":"^1.0.1","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^4.0.1","load-grunt-tasks":"^4.0.0","tsd":"^0.7.1","xo":"^0.16.0"},"types":"dist/screenfull.d.ts","xo":{"envs":["node","browser"]},"gitHead":"67d92b14e6c3ebe92f9faa1844b293f230333b1f","bugs":{"url":"https://github.com/sindresorhus/screenfull.js/issues"},"homepage":"https://github.com/sindresorhus/screenfull.js#readme","_id":"screenfull@5.0.2","_nodeVersion":"10.18.1","_npmVersion":"6.13.7","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-cCF2b+L/mnEiORLN5xSAz6H3t18i2oHh9BA8+CQlAh5DRw2+NFAGQJOSYbcGw8B2k04g/lVvFcfZ83b3ysH5UQ==","shasum":"b9acdcf1ec676a948674df5cd0ff66b902b0bed7","tarball":"http://registry-npm.ywwl.com/screenfull/download/screenfull-5.0.2.tgz","fileCount":5,"unpackedSize":17611,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRSINCRA9TVsSAnZWagAAl4oP/3u/6FuEVYjHXcbYpKN2\nMT3Aex0vsLPfmtWFFOjNIeXyF9EZfOQstQDAhCr9fTf0hjbBZypaQ93jNZJ6\nzLi2hfMWE6CdO2+/7MOf0EYmRhQaSzkZseEetXYGJROp4D4UGSkp9+w4lixp\n5LfR+v/RrNb13JqcD0tJc3cesaeHGMxNQVPO/Iq1SzkYheQ2PXY1iehyJAnA\n8NJtIIYUJJLb9aTN9C4zTjRl0qYG2WjSvzVib+Vn8YL8oXZkicoGgGK1Rrk5\nM5DQ7dfCZrZ15guyWyOwS7jf/QrblpDVceOVqVYlqGEtPTxs4xq3axd9FdyN\nTqUJolHylMbISw6IQRGO7FGM1LHsGMgY0sKhs6PwzXkc0GmLPVQVwmCd8WP8\n6ejr6ZSDhadEayKxumqWxDY++KezeQJ0km6DpmMyuCEges5f9eIv7ew8cZMG\nVN2/gOFK8lzYFKhAro2xAaU+2y7IlMs0WrAdQ8AavSGK0zpOEjcNGSePAHyS\nzY/2Hu1enjLd6B7FMkJOnd1EFu+LDE67SM2Qv+gU1AN2LnVXbdHKWu9+JAw7\nw2FmqBQrlwXbnyOswk3eIar9jNk/vbzjbjW+4+kxuf/txrQXWCxhByGCds4A\noORYFSQzM+dNmWkvsYx0/iSVt7f0yP4zj16pD+0ZYfBywC39mVrd0fsbISZT\nbvAA\r\n=+2Ep\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEo5RfVDZcXfmr7HyK5g2CnBjWTugCNFLIziKxp3Z6TmAiEA4oSI9i776BFOARzD0IfK0FCRl1G5wEB7KwkmhTrKeGc="}],"size":5456,"noattachment":false,"key":"/screenfull/-/screenfull-5.0.2.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/screenfull_5.0.2_1581589005412_0.23531504667729597"},"_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":1581589005535,"_cnpm_publish_time":1581589005535,"dist-tags":{"latest":"6.0.2"}}