Advertisement
Dimalolzet

Aquamarin carousel

Jun 9th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. initCarousel = function() {
  2.     'use strict';
  3.     var $titlePrimary, $titleSecondary;
  4.     $titlePrimary = $('.intro__title_primary');
  5.     $titleSecondary = $('.intro__title_secondary');
  6.     return $('.carousel-block').each(function() {
  7.         var $carousel, arrows, center, count, infinite, ref, ref1, ref2, ref3, ref4, ref5, responsive, speed, swipe;
  8.         $carousel = $(this).find('.carousel');
  9.         count = (ref = $carousel.data('count')) != null ? ref : 1;
  10.         arrows = (ref1 = $carousel.data('arrows')) != null ? ref1 : false;
  11.         center = (ref2 = $carousel.data('center')) != null ? ref2 : false;
  12.         speed = (ref3 = $carousel.data('speed')) != null ? ref3 : 300;
  13.         infinite = (ref4 = $carousel.data('infinite')) != null ? ref4 : true;
  14.         swipe = windowWidth <= 992;
  15.         responsive = (ref5 = $carousel.data('responsive')) != null ? ref5 : [{
  16.             breakpoint: 992,
  17.             settings: {
  18.                 slidesToShow: 1,
  19.                 centerMode: false
  20.             }
  21.         }];
  22.         $carousel.slick({
  23.             slidesToShow: count,
  24.             slidesToScroll: 1,
  25.             swipe: swipe,
  26.             pauseOnHover: false,
  27.             autoplay: true,
  28.             autoplaySpeed: 5000,
  29.             speed: speed,
  30.             arrows: arrows,
  31.             centerMode: center,
  32.             infinite: infinite,
  33.             prevArrow: $(this).find('.carousel__button_prev'),
  34.             nextArrow: $(this).find('.carousel__button_next'),
  35.             responsive: responsive
  36.         });
  37.         if ($carousel.hasClass('intro-carousel')) {
  38.             $carousel.on('beforeChange', function(event, slick, currentSlide, nextSlide) {
  39.                 var $activeSlide;
  40.                 $activeSlide = $(slick.$slides[nextSlide]);
  41.                 $titlePrimary.text($activeSlide.data('title'));
  42.                 return $titleSecondary.text($activeSlide.data('caption'));
  43.             });
  44.             return $carousel.slick('slickGoTo', 0);
  45.         }
  46.     });
  47. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement