This plugin will listen when switching between browser tabs using the HTML5 Visibility API. And will also listen for browser window focus and blur events. Add your code to pause and resume when leaving and returning to your webpage.
Orignal by Jonathan Marzullo, Source
// TabWindowVisibilityManager
$(window).TabWindowVisibilityManager({
onFocusCallback: function(){
// resume() code goes here
},
onBlurCallback: function(){
// pause() code goes here
}
});
Download from the project page.
Install with Bower: bower install --save tatundkraft/TabWindowVisibilityManager