Hullo JS
Search…
pageVisibility
import { pageVisibility } from '@hullo/browser'
An Observable of string values that are emitted with visibilitychange event.
1
import { pageVisibility } from '@hullo/browser';
2
​
3
const visibility$ = pageVisibility();
4
​
5
visibility$.subscribe({
6
next(visibility) {
7
switch(visibility) {
8
case "prerender":
9
console.log('where are you?');
10
break;
11
​
12
case "hidden":
13
console.log('peeka');
14
break;
15
​
16
case "visible":
17
console.log('boo');
18
break;
19
}
20
}
21
})
Copied!
Last modified 2yr ago
Copy link