diff --git a/README.md b/README.md index 3d9e9cb..c518561 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ npm install --save toggle-fullscreen ## Usage ```js +const toggleFullscreen = require('toggle-fullscreen'); onChangeFullScreen = function() { const element = document.getElementById('something'); toggleFullscreen(element).then(function(isFullScreen) { @@ -30,6 +31,7 @@ onChangeFullScreen = function() { For async/await: ```js +const toggleFullscreen = require('toggle-fullscreen'); onChangeFullScreen = async () => { const element = document.getElementById('something'); const isFullScreen = await toggleFullscreen(element); @@ -45,18 +47,19 @@ onChangeFullScreen = async () => { For callback (use if something is wrong with Promise) : ```js - onChangeFullScreen = function() { - const element = document.getElementById('something'); - toggleFullscreen(element, function(isFullScreen) { - if (isFullScreen) { - // any process in fullscreen mode - // e.g.document.addEventListener('keydown', this.keydownEvent); - } else { - // any process in non-fullscreen mode - // e.g.document.removeEventListener('keydown', this.keydownEvent); - } - }); - }; +const toggleFullscreen = require('toggle-fullscreen'); +onChangeFullScreen = function() { + const element = document.getElementById('something'); + toggleFullscreen(element, function(isFullScreen) { + if (isFullScreen) { + // any process in fullscreen mode + // e.g.document.addEventListener('keydown', this.keydownEvent); + } else { + // any process in non-fullscreen mode + // e.g.document.removeEventListener('keydown', this.keydownEvent); + } + }); +}; ``` ## Support - Chrome@latest diff --git a/package.json b/package.json index 2b32006..3842bb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "toggle-fullscreen", - "version": "0.2.0", + "version": "0.2.1", "description": "Simple to use Fullscreen API with Promise for cross-browser.", "main": "index.js", "scripts": {