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, speed, swipe;
- $carousel = $(this).find('.carousel');
- count = $carousel.data('count' != null ? 'count' : 1);
- arrows = $carousel.data('arrows' != null ? 'arrows' : false);
- center = $carousel.data('center' != null ? 'center' : false);
- speed = $carousel.data('speed' != null ? 'speed' : 300);
- swipe = windowWidth <= 992;
- $carousel.slick({
- slidesToShow: count,
- slidesToScroll: 1,
- swipe: swipe,
- pauseOnHover: false,
- autoplay: true,
- autoplaySpeed: 5000,
- speed: speed,
- arrows: arrows,
- centerMode: center,
- prevArrow: $(this).find('.carousel__button_prev'),
- nextArrow: $(this).find('.carousel__button_next'),
- responsive: [{
- breakpoint: 992,
- settings: {
- slidesToShow: 1,
- centerMode: false
- }
- }]
- });
- 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