Hello,
I have a slideshow which basically changes the src attribute of an image and fading it in and out.
function startSlideshow() {
if (i >= images.length) { i = 0 }
var path = images[i].path;
var name = images[i].name;
i++;
image.attr('src', path)
image.animate({opacity:1}, 1000)
.delay(5000)
.animate({opacity:0}, 500, startSlideshow);
}
This works.
I also have something I call an image picker. It looks something like this:
<ul id="ImagePicker">
<li>•</li>
<li>•</li>
<li>•</li>
</ul>
When you click on one of the li items the slideshow should show the corresponding image.
$('#ImagePicker li').click(function () {
image.stop(true, false)
.animate({ opacity: 0 }, 10, startSlideshow);
});
The problem is that it sometimes gets bugging and I am not sure why it happens. If you click during the fadeout(I think) .animate({opacity:0}, 500, startSlideshow) it starts going faster.
Anybody know why this might happen?
Update
Actually it seems that it's happening during delay and not during the animate.
Update 2
I could fix it like this but it feels a little hacky:
image.animate({ opacity: 1 }, 1000)
.animate({ opacity: 1 }, 5000)
.animate({opacity:0}, 1000, startSlideshow);