mirror of
https://github.com/chatwoot/chatwoot.git
synced 2026-06-22 21:04:08 +08:00
https://github.com/user-attachments/assets/52ecf3f8-0329-4268-906e-d6102338f4af --------- Co-authored-by: Pranav <[email protected]> Co-authored-by: Pranav <[email protected]>
22 lines
435 B
JavaScript
22 lines
435 B
JavaScript
export class WindowVisibilityHelper {
|
|
constructor() {
|
|
this.isVisible = true;
|
|
this.initializeEvent();
|
|
}
|
|
|
|
initializeEvent = () => {
|
|
window.addEventListener('blur', () => {
|
|
this.isVisible = false;
|
|
});
|
|
window.addEventListener('focus', () => {
|
|
this.isVisible = true;
|
|
});
|
|
};
|
|
|
|
isWindowVisible() {
|
|
return !document.hidden && this.isVisible;
|
|
}
|
|
}
|
|
|
|
export default new WindowVisibilityHelper();
|