We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.
(function(){
var _origRAF = window.requestAnimationFrame;
var _lastRAF = null;
window.requestAnimationFrame = function(cb) {
_lastRAF = _origRAF.call(window, cb);
return _lastRAF;
};
window.addEventListener('beforeunload', function() {
if (_lastRAF) cancelAnimationFrame(_lastRAF);
});
// Also cancel on visibility change (tab switch)
document.addEventListener('visibilitychange', function() {
if (document.hidden && _lastRAF) {
cancelAnimationFrame(_lastRAF);
}
});
})();