Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Masashi Hirano committed Aug 24, 2017
1 parent d697034 commit a55c839
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit a55c839

Please sign in to comment.