Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- initCarousel = function() {
- 'use strict';
- var $titlePrimary, $titleSecondary;
- $titlePrimary = $('.intro__title_primary');
- $titleSecondary = $('.intro__title_secondary');
- return $('.carousel-block').each(function() {
- var $carousel, arrows, center, count, infinite, ref, ref1, ref2, ref3, ref4, ref5, responsive, speed, swipe;
- $carousel = $(this).find('.carousel');
- count = (ref = $carousel.data('count')) != null ? ref : 1;
- arrows = (ref1 = $carousel.data('arrows')) != null ? ref1 : false;
- center = (ref2 = $carousel.data('center')) != null ? ref2 : false;
- speed = (ref3 = $carousel.data('speed')) != null ? ref3 : 300;
- infinite = (ref4 = $carousel.data('infinite')) != null ? ref4 : true;
- swipe = windowWidth <= 992;
- responsive = (ref5 = $carousel.data('responsive')) != null ? ref5 : [{
- breakpoint: 992,
- settings: {
- slidesToShow: 1,
- centerMode: false
- }
- }];
- $carousel.slick({
- slidesToShow: count,
- slidesToScroll: 1,
- swipe: swipe,
- pauseOnHover: false,
- autoplay: true,
- autoplaySpeed: 5000,
- speed: speed,
- arrows: arrows,
- centerMode: center,
- infinite: infinite,
- prevArrow: $(this).find('.carousel__button_prev'),
- nextArrow: $(this).find('.carousel__button_next'),
- responsive: responsive
- });
- if ($carousel.hasClass('intro-carousel')) {
- $carousel.on('beforeChange', function(event, slick, currentSlide, nextSlide) {
- var $activeSlide;
- $activeSlide = $(slick.$slides[nextSlide]);
- $titlePrimary.text($activeSlide.data('title'));
- return $titleSecondary.text($activeSlide.data('caption'));
- });
- return $carousel.slick('slickGoTo', 0);
- }
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement