-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.js
32 lines (31 loc) · 1.04 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { IdleJs } from './lib/main.js'
var initialDelay = 2000
console.log(`initialize trigger in: ${initialDelay}`)
var idle = new IdleJs({
onIdle: function(){
document.querySelector('#status').classList.toggle('idle');
document.querySelector('#status').textContent = 'Idle!';
},
onActive: function(){
document.querySelector('#status').classList.toggle('idle');
document.querySelector('#status').textContent = 'Active!';
},
onHide: function(){
document.querySelector('#visibility').classList.toggle('idle');
document.querySelector('#visibility').textContent = 'Hidden!';
},
onShow: function(){
// Add a slight pause so you can see the change
setTimeout(function(){
document.querySelector('#visibility').classList.toggle('idle');
document.querySelector('#visibility').textContent = 'Visible!';
}, 250);
},
idle: initialDelay,
keepTracking: true
}).start();
window.setTimeout( () => {
let newDelay = 5000;
idle.set({idle: newDelay});
console.log(`now triggering in: ${newDelay}`)
}, 15*1000)