(function($) {
if (!Modernizr.touch) {
//only do slider animation for desktop only not touch device
$('.ani-slider').on('init', function(e, slick) {
var $firstAnimatingElements = $('div.slide').find('[data-animation]');
doAnimations($firstAnimatingElements);
});
$('.ani-slider').on('beforeChange', function(e, slick, currentSlide, nextSlide) {
var $animatingElements = $('div.slide[data-slick-index="' + nextSlide + '"]').find('[data-animation]');
doAnimations($animatingElements);
});
function doAnimations(elements) {
var animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
elements.each(function() {
var $this = $(this);
var $animationDelay = $this.data('delay');
var $animationDuration = $this.data('duration');
var $animationType = 'p-tick ' + $this.data('animation');
$this.css({
'animation-delay': $animationDelay,
'-webkit-animation-delay': $animationDelay,
'-webkit-animation-duration': $animationDuration,
'animation-duration': $animationDuration,
});
$this.addClass($animationType).one(animationEndEvents, function() {
$this.removeClass($animationType);
});
});
}
}
//slider for home slider
$('.home-slider').slick({
autoplay: true,
dots: false,
autoplay: true,
nextArrow: '',
prevArrow: '',
speed: 800,
fade: true,
pauseOnHover: false,
pauseOnFocus: false
});
//slider for page slider
$('.page-head-slider').slick({
autoplay: true,
dots: false,
autoplay: true,
arrows: false,
speed: 800,
fade: true,
pauseOnHover: false,
pauseOnFocus: false
});
$(".slider-img-bg").each(function() {
var imG = $(this).data('background');
$(this).css('background-image', "url('" + imG + "') "
);
});
})(jQuery);