Created
April 25, 2017 11:28
-
-
Save kirandash/67da0c020f3618de2f65742738234e17 to your computer and use it in GitHub Desktop.
Slick slider with animate.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#banner-home .slick-home-banner').on('init', function(e, slick) { | |
var $firstAnimatingElements = $('div.banner-item:first-child').find('[data-animation]'); | |
doAnimations($firstAnimatingElements); | |
}); | |
$('#banner-home .slick-home-banner').on('beforeChange', function(e, slick, currentSlide, nextSlide) { | |
var $animatingElements = $('div.banner-item[data-slick-index="' + nextSlide + '"]').find('[data-animation]'); | |
doAnimations($animatingElements); | |
}); | |
$('#banner-home .slick-home-banner').slick({ | |
autoplay: true, | |
autoplaySpeed: 8000, | |
speed: 2000, | |
dots: true, | |
fade: true, | |
prevArrow: false, | |
nextArrow: false | |
}); | |
function doAnimations(elements) { | |
var animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; | |
elements.each(function() { | |
var $this = $(this); | |
var $animationDelay = $this.data('delay'); | |
var $animationType = 'animated ' + $this.data('animation'); | |
$this.css({ | |
'animation-delay': $animationDelay, | |
'-webkit-animation-delay': $animationDelay | |
}); | |
$this.addClass($animationType).one(animationEndEvents, function() { | |
$this.removeClass($animationType); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please add a webpage with full example of this.