I am making a slider using slick carousel
and i want caption
animation using animate
css while the slide is active
.
The animation works fine on first slide when load but after that, the animation is not working on other slides.
Here is my HTML
<div id="hero-slider">
<div>
<img src="http://lorempixel.com/1920/500/abstract/1" alt="">
<div class="caption">
<h3>We push the edge of</h3>
<h2>what’s<br/>possible.123</h2>
</div>
</div>
<div>
<img src="http://lorempixel.com/1920/500/abstract/2" alt="">
<div class="caption">
<h3>We push the edge of</h3>
<h2>what’s<br/>possible.456</h2>
</div>
</div>
</div>
Here is the SCSS
body {
padding: 0;
margin: 0;
}
#hero-slider {
.caption {
position: absolute;
left: 10%;
top: 10%;
h2,h3 {
color: white;
}
}
}
and the jQuery
which i am using
$(document).ready(function(){
$('#hero-slider').slick({
autoplay: true,
autoplaySpeed: 4000,
dots: true,
fade: true
});
if ($('.slick-slide').hasClass('slick-active')) {
$('.caption').addClass('animated fadeInLeft');
} else {
$('.caption').removeClass('animated fadeInLeft');
}
});
Here is the Fiddle