Created
January 28, 2022 14:27
-
-
Save Gummiees/6a72c46e17a0e881f508d2fec643af9a to your computer and use it in GitHub Desktop.
Detect with Angular when the user sends the site to the background/foreground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@HostListener('document:visibilitychange', ['$event']) | |
visibilitychange() { | |
if (document.visibilityState === 'hidden') { | |
console.log('hidden'); | |
} else { | |
console.log('visible'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment