1.0.1 • Published 5 years ago
is-afk v1.0.1
is-afk
small library that allows you to react to various useragent states (idle, hidden, visible)
Why
This library is inspired by ifvisible.js. It tries to be more minimal:
- no event emitter, just a simple callback once the state changes
- Hidden doesn't imply Idle
Usage
const afk = new Afk(() => {
if (afk.is(State.Hidden)) {
// document is hidden
} else {
// document is visible
}
if (afk.is(State.Idle)) {
// user is idle in document
}
});