I am currently working with AngularJs version 1.4 and I need to be able to detect when a user is not on the tab of my app and when they return. To achieve this, I attempted using $watch in the following way:
$rootScope.$watch(angular.bind($window, function(document){
return this.document.visibilityState
}), function (n, o) {
if (n === 'visible' && o == 'hidden') {
console.log('I'm back')
}
})
The issue I am facing is that when I switch back to the tab, there is a significant delay before the response function triggers the change, approximately around 5 seconds.
Does anyone have any insight into why this might be happening?