in my code i've got a situation like this:
var t = setInterval(function(e) {
if (document.hasFocus()) {
// Tab Has Focus so,
// Execute some actions
}
},4000);
I've a jQuery interval that every 4 seconds execute some actions. Like animate objects and adding css classes to my DOM.
The problem is that when i change tab ('blur' window event) and then re-add the focus event are re executed.
Is there a method that let the current actions finish and then stop the interval and then resume when page is focused?