I have a custom made slideshow object to perform the usual stuff the name indicates on a website. It all works well except when I switch tabs in Chrome and come back to the
Chrome (and apparently the latest versions of Firefox too) reduce the speed of setInterval when the tab is in the background to improve foreground performance. This probably matters the most when there are fast running timer-driven animations in background pages. When the page comes back to the foreground, it "tries" to catch up and runs a bunch of setInterval calls much faster than they would normally run.
The work-arounds are:
setInterval so Chrome won't mess with it (you'd have to look up what that time is).setTimeout instead of setInterval with some type of repeated setTimeout like this:Code:
function nextSlide() {
// show next slide now
// set timer for the slide after this one
setTimeout(function() {
nextSlide(); // repeat
}, xxx)
}
Similar post here.