{"name":"screenfull","version":"5.0.0","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"},"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":"b2a50cc4d1554ef62530a4cae973096a96921c93","bugs":{"url":"https://github.com/sindresorhus/screenfull.js/issues"},"homepage":"https://github.com/sindresorhus/screenfull.js#readme","_id":"screenfull@5.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-yShzhaIoE9OtOhWVyBBffA6V98CDCoyHTsp8228blmqYy1Z5bddzE/4FPiJKlr8DVR4VBiiUyfPzIQPIYDkeMA==","shasum":"5c2010c0e84fd4157bf852877698f90b8cbe96f6","tarball":"http://registry-npm.ywwl.com/screenfull/download/screenfull-5.0.0.tgz","fileCount":5,"unpackedSize":16666,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJddknLCRA9TVsSAnZWagAAfDIP/inWK97m0N5UQjKaW2Dp\nbrNZDM3KVUPIXvvGXbyHpFKj+aMvPfGxShFfW1lUjeKiWrwJk8PjZmUnHJiT\nhO/Vlt8WkjNY7l+Q3QDdfAi0SxI5PCRDRpn0DFbMO0SzEHBCJuZrW7Es9MX2\n8DdQ9IWTNTxebSMm/8ZVgaWaCAgrYT8MRHDQffczDrLKl4lRVc4rDPiO3oBq\n4GlCzH/PZ8VkGfJQxiuyer3vrXtRg4b8AbtUK+sR1+EncqbJMw/n3QZf1pvp\nbuB6TcTM551rbiGiDpoOhuaLM9dMeL+4C7W4MO+WNX93HLsXPkWz4tpZIpzK\nizLxlUmgwMVtb8j7/Khguj/7VaX8bv8NFEV1frtY1pZRkjJKNwmuktf7nP8R\n2Genx+KCmFXwEZyehyILV7IKfWAMGWxxfPj/XS13rXrCv1uF9dD+5WzeroNd\nBbGWpIE01e4O658nzf/uRRKi5KPFdVJcVrVYZ4R/8kLCswEI58cC4nPh9E9S\nzg72hFuZRQsOoOseyvKMxIWooLP9QO98TgIxfbGZ1x83XwZJBnOuxewhaKZR\nKatcC4WQ9xvrkcQbf1Q3ZdsAsvq8eOA4d96C0nIUqFnjl8kAkz3fA5dYIf/A\ntPIYtPNNgoS+gdnwLTK6Dq6gtSA5Jm3axK3BZ+7O9ksllQvXD1JTgbARmMdA\nDgMt\r\n=KXYN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEl6q8lS/xi2b9UzUms1jmevERnvlmBK0XdzTQ8/+FWiAiASdVysqv8R7iVuCMhFBwqsuN/6iKvxXA0O8aLLb/HrCQ=="}],"size":5101,"noattachment":false,"key":"/screenfull/-/screenfull-5.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/screenfull_5.0.0_1568033226942_0.252839979796468"},"_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":1568033227084,"_cnpm_publish_time":1568033227084,"dist-tags":{"latest":"6.0.2"}}