I am trying to load three images, each has an animation fadeIn delay, What I want is to fade them all in, with their respective delays then hide. then fadeIn again then repeat. Animation flow Example: 1. FadeIn image1 delay=0s /image2 delay=0.5s /image3 delay=1 /s 2. Hide all three images on 1.5s 3. Repeat FadeIn on 2s Here's what I have done, I am playing with add and remove class in setInterval.
$(".tri1").inViewport(function(px) {
if (px > 0) {
fadeAdd();
setInterval(function() {
fadeAdd();
}, 5500);
setInterval(function() {
fadeRemove();
$(".tri1").css('opacity', '0');
$(".tri2").css('opacity', '0');
$(".tri3").css('opacity', '0');
}, 5400);
}
});
function fadeAdd() {
$(".tri1").addClass("fadeIn");
$(".tri2").addClass("fadeIn");
$(".tri3").addClass("fadeIn");
}
function fadeRemove() {
$(".tri1").removeClass("fadeIn");
$(".tri2").removeClass("fadeIn");
$(".tri3").removeClass("fadeIn");
}
.tri2{
animation-delay: 0.5s;
}
.tri3{
animation-delay: 1s;
}
<div class="pointer">
<img class="tri1 animated" src="res/img/sec4/tri1.png" alt="" />
<img class="tri2 animated" src="res/img/sec4/tri2.png" alt="" />
<img class="tri3 animated" src="res/img/sec4/tri3.png" alt="" />
</div>