I made a slideshow with Jquery
using setInterval
to change the slides after a few seconds. It works fine, however, if I change tabs and spend some time back, the animation gets "bugged" and passes the slides very fast.
Here is the website . The opening slide is the first slide you see.
Slideshow Code
<div class="slideshow">
<img src="images/152156263613548.jpg" class="slide slide1 active_slide" data-slide="1">
<img src="images/capaaaa.jpg" class="slide slide2" data-slide="2">
<img src="images/casa_das_artes.jpg" class="slide slide3" data-slide="3">
</div>
setInterval(function(){
var slide = $(".active_slide").attr("data-slide");
var next = parseInt(slide)+1;
if($(".slide"+next).length > 0){
$(".slide"+slide).removeClass("active_slide");
$(".slide"+slide).fadeOut(1000);
$(".slide"+next).addClass("active_slide");
$(".slide"+next).fadeIn(700).css("display","block");;
}else{
$(".slide"+slide).removeClass("active_slide");
$(".slide"+slide).fadeOut(1000);
$(".slide1").addClass("active_slide");
$(".slide1").fadeIn(700).css("display","block");;
}
},4000);