{"name":"screenfull","version":"3.2.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"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"main":"dist/screenfull.js","files":["dist/screenfull.js"],"keywords":["browser","fullscreen"],"devDependencies":{"grunt":"^1.0.1","grunt-contrib-concat":"^1.0.0","grunt-contrib-uglify":"^2.0.0","load-grunt-tasks":"^3.3.0","xo":"^0.16.0"},"scripts":{"test":"xo"},"xo":{"envs":["node","browser"]},"gitHead":"fc1fe769039382d7168711fee7ef7d467691e399","bugs":{"url":"https://github.com/sindresorhus/screenfull.js/issues"},"homepage":"https://github.com/sindresorhus/screenfull.js#readme","_id":"screenfull@3.2.2","_shasum":"ddd0c2c66a799640a566d95672d79abac4d627aa","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"ddd0c2c66a799640a566d95672d79abac4d627aa","tarball":"http://registry-npm.ywwl.com/screenfull/download/screenfull-3.2.2.tgz","integrity":"sha512-dTyAZovBe77DCNL59F+Bu937dTtgoxb/USIFEjsPGwOvl3lhNNLPG++O8Y7KOaI0qbkf03xotpEyX7PI3ljJCw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDeNzaMIRTSFrV2aGXwOhgFbFn19Y2+AnwPvVUUv9iQ3QIhAKrZByby21Rczb4viIGPhaN5VI0xMVGuSonQGoJYe3gr"}],"size":4497,"noattachment":false,"key":"/screenfull/-/screenfull-3.2.2.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/screenfull-3.2.2.tgz_1497456687572_0.46956563577987254"},"directories":{},"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":1497456688567,"_cnpm_publish_time":1497456688567,"dist-tags":{"latest":"6.0.2"}}