javascript - Strange setInterval behavior while tab is switched -
i have banner this:
http://jsfiddle.net/ek658cmz/1/
it's using several intervals make animation (i can't use jquery or that, in project), , perfect, before switch tab. if switch tab , return after seconds animation isn't working properly, looks several animations trying ran @ same time. interesting, if switchback instantly banner tab, okay, more time "out" - more glitches get.
i've tried clearinterval on window blur
window.addeventlistener('blur', function () { banner.stopanimation(); }, false);
like that, tried play animation initiations
window.addeventlistener('load', function () { banner.init(); }, false); window.addeventlistener('focus', function () { banner.init(); }, false);
there several atempts reload page on blur location.reload(), no success.
what noticed, when blur window opening window somewhere, animation ended normally, , wont start, when switch time, animation ticking in background each second
there 1 nuance here also, banner must ran in iframe.
Comments
Post a Comment