I have created a carousel with Javascript. I am using animate.css
which can enable me to use some cool transitions. I have a class called fadeInLeft
also applied to each div
. I am now trying to remove fadeInLeft
and add FadeOutLeft
to make the transition smooth. However, at the moment everything I have tried just makes the current slide disappear sharply. The idea after the current slide has faded out to the left I would like the next slide to fade in from the left. Can anyone please advice me how I could achieve this?
var index = 1;
function plusIndex(n) {
index = index + 1;
showImage(index);
}
showImage(1);
function showImage(n){
var i;
var x = document.getElementsByClassName("carousel");
if(n > x.length){index = 1};
if(n< 1){ index = x.length};
for(i=0;i<x.length;i++)
{
x[i].style.display = "none";
}
x[index-1].style.display = "block";
}
<i type="button" onclick="plusIndex(-1)" class="fa fa-chevron-left arrowLeft arrow" aria-hidden="true"></i>
<i type="button" onclick="plusIndex(1)" class="fa fa-chevron-right arrowRight arrow" aria-hidden="true"></i>
<div class="carousel carousel1 animated fadeInLeft"></div>
<div class="carousel carousel2 animated fadeInLeft"></div>
<div class="carousel carousel3 animated fadeInLeft"></div>