I have a loop that fades between images, with an interval set by the variable itemInterval. Like so:
// interval between items
var itemInterval = 5500;
// start loop
var infiniteLoop = setInterval(function() {
// initial fade out
$('.rotating-item').eq(currentItem).fadeOut(fadeTime);
// set counter
if (currentItem == numberOfItem -1) {
currentItem = 0;
} else {
currentItem++;
}
// next item fade in
$('.rotating-item').eq(currentItem).fadeIn(fadeTime);
}, itemInterval);
What I would really like to do, if have an initial time interval that runs only the first time the loop is run, and then a second time interval that runs each time afterwards.
So when the user opens the page, the first cross-fade is quite quick, but then they wait longer for the next image to cross-fade.
I’m quite new to Javascript, so I’d really appreciate it if you could edit my code to make it work and let me know what you’ve done. if Thanks in advance for your time 🙂
You could try using a normal function instead of an anonymous one:
This way, you could call this function manually, and then commence it’s interval.