Comparing version 1.2.0 to 2.0.0-beta.1
{ | ||
"name": "idle-js", | ||
"version": "1.2.0", | ||
"description": "Detect user idleness", | ||
"main": "dist/Idle.js", | ||
"version": "2.0.0-beta.1", | ||
"description": "Detect user idleness. In other words, play with activity state.", | ||
"scripts": { | ||
"build": "gulp build", | ||
"coverage": "gulp coverage", | ||
"lint": "gulp lint", | ||
"prepare": "gulp build", | ||
"build-example": "npx webpack --mode=development ./example/webpack/entry.js -o ./example/webpack/bundle.js" | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"files": [ | ||
"/dist" | ||
], | ||
"repository": { | ||
@@ -17,8 +17,19 @@ "type": "git", | ||
}, | ||
"browserslist": [ | ||
"defaults", | ||
"not IE 11" | ||
], | ||
"devDependencies": { | ||
"eslint": "^8.6.0", | ||
"eslint-plugin-compat": "^4.0.0", | ||
"vite": "^2.7.2" | ||
}, | ||
"keywords": [ | ||
"idle", | ||
"events", | ||
"interactivity" | ||
"interactivity", | ||
"timeout", | ||
"activity", | ||
"user state" | ||
], | ||
"author": "hugohil <hugo@soixantecircuits.fr>", | ||
"license": "MIT", | ||
@@ -28,3 +39,3 @@ "bugs": { | ||
}, | ||
"homepage": "https://github.com/soixantecircuits/idle-js", | ||
"author": "hugohil <hilairehugo@gmail.com>", | ||
"contributors": [ | ||
@@ -35,36 +46,3 @@ "massambadiouf <mass@soixantecircuits.fr> (https://github.com/massambadiouf)", | ||
"Martin Hradil <mhradil@redhat.com> (https://github.com/himdel)" | ||
], | ||
"files": [ | ||
"/dist" | ||
], | ||
"dependencies": { | ||
"@babel/polyfill": "^7.2.5" | ||
}, | ||
"browserslist": "> 0.25%, not dead", | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/preset-env": "^7.3.1", | ||
"@babel/register": "^7.0.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-loader": "^8.0.5", | ||
"babel-plugin-transform-object-assign": "^6.3.13", | ||
"del": "^3.0.0", | ||
"gulp": "^4.0.0", | ||
"gulp-babel": "^8.0.0-beta.2", | ||
"gulp-eslint": "^5.0.0", | ||
"gulp-filter": "^5.1.0", | ||
"gulp-load-plugins": "^1.5.0", | ||
"gulp-plumber": "^1.2.1", | ||
"gulp-rename": "^1.4.0", | ||
"gulp-sourcemaps": "^2.6.4", | ||
"gulp-uglify": "^1.5.1", | ||
"gulp-util": "^3.0.8", | ||
"webpack": "^4.29.2", | ||
"webpack-cli": "^3.2.3", | ||
"webpack-stream": "^5.2.1" | ||
}, | ||
"babelBoilerplateOptions": { | ||
"entryFileName": "index.js", | ||
"mainVarName": "IdleJs" | ||
} | ||
] | ||
} |
# idle-js | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) | ||
⏲ | ||
`npm install idle-js --save` | ||
A really simple utility module for tracking user activity on a tab. Usefull to change the tab name, or creating micro interaction in your webapp. | ||
## Usage | ||
- returning to a particular after no activity identified | ||
- display a modal depending on activity | ||
- change things while the user is away | ||
- create anything funny :) | ||
>Warning IE11 is not supported by default anymore. If you want to use it, you might want to add a polyfill for `Object.assign` -> https://www.jsdelivr.com/package/npm/polyfill-object-assign | ||
## Install | ||
`npm i idle-js` | ||
## Browsers support | ||
![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![IE](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ||
--- | --- | --- | --- | --- | | ||
Latest ✔ | Latest ✔ | 10+ ✔ | Latest ✔ | 6.1+ ✔ | | ||
## Usage in your script | ||
```js | ||
@@ -14,17 +31,31 @@ // Those are the default values | ||
events: ['mousemove', 'keydown', 'mousedown', 'touchstart'], // events that will trigger the idle resetter | ||
onIdle: function () {}, // callback function to be executed after idle time | ||
onActive: function () {}, // callback function to be executed after back form idleness | ||
onHide: function () {}, // callback function to be executed when window become hidden | ||
onShow: function () {}, // callback function to be executed when window become visible | ||
onIdle: , // callback function to be executed after idle time | ||
onActive: , // callback function to be executed after back form idleness | ||
onHide: , // callback function to be executed when window become hidden | ||
onShow: , // callback function to be executed when window become visible | ||
keepTracking: true, // set it to false if you want to be notified only on the first idleness change | ||
startAtIdle: false // set it to true if you want to start in the idle state | ||
}); | ||
idle.start(); | ||
}) | ||
``` | ||
// In case stopping is needed | ||
idle.stop() // stops all tracking | ||
To start observing the state of the tab: | ||
`idle.start()` | ||
If you need to stop observing: | ||
`idle.stop()` // stops all tracking | ||
You can then reset and start again: | ||
``` | ||
idle.stop() | ||
.reset() // reset visible and idle state to initial values | ||
.start(); | ||
.start() // restart | ||
``` | ||
// Reset to a specific state | ||
Reset to a specific state | ||
``` | ||
idle.reset({ | ||
@@ -36,11 +67,11 @@ idle: false, | ||
## Running examples | ||
## Running example | ||
#### Webpack: | ||
### Simply start the server [Vite](https://vitejs.dev/) | ||
* Run the command `npx webpack ./example/webpack/entry.js ./example/webpack/bundle.js`. | ||
* Open `./example/webpack/index.html` in your browser. | ||
`pnpm dev -- --port 3030` | ||
#### In browser: | ||
Need to choose an other port ? `pnpm dev -- --port 6060` | ||
* Open `./example/vanilla/index.html` | ||
Open the local url, in your browser: `http://localhost:3030` or `http://localhost:THE_PORT_YOU_CHOOSE` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
3
76
3632
2
0
2
2
- Removed@babel/polyfill@^7.2.5
- Removed@babel/polyfill@7.12.1(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedregenerator-runtime@0.13.11(transitive)