Advertisement
salmancreation

slick carousel

Dec 5th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // slick carousel
  2.     var time = 2;
  3.     var $bar,
  4.     $slick,
  5.     isPause,
  6.     tick,
  7.     percentTime;
  8.  
  9.     $slick = $('.product-carousel-list');
  10.     $slick.slick({
  11.     speed: 1200,
  12.     arrows: true,
  13.     infinite: true,
  14.     slidesToShow: 5,
  15.     slidesToScroll: 4,
  16.     focusOnSelect: true,
  17.     prevArrow: $('.slider-arrow.left'),
  18.     responsive: [
  19.         {
  20.           breakpoint: 1024,
  21.           settings: {
  22.             slidesToShow: 2,
  23.             slidesToScroll: 2,
  24.           }
  25.         },
  26.         {
  27.           breakpoint: 600,
  28.           settings: {
  29.             slidesToShow: 1,
  30.             slidesToScroll: 1
  31.           }
  32.         },
  33.         {
  34.           breakpoint: 480,
  35.           settings: {
  36.             slidesToShow: 1,
  37.             slidesToScroll: 1
  38.           }
  39.         }
  40.     ]
  41.        
  42.     });
  43.  
  44.     $bar = $('.slider-progress .progress');
  45.  
  46.     function startProgressbar() {
  47.     resetProgressbar();
  48.     percentTime = 0;
  49.     isPause = false;
  50.     tick = setInterval(interval, 30);
  51.     }
  52.  
  53.     function interval() {
  54.     if (isPause === false) {
  55.       percentTime += 1 / (time + 0.1);
  56.       $bar.css({
  57.         width: percentTime + "%"
  58.       });
  59.       if (percentTime >= 100) {
  60.         $slick.slick('slickNext');
  61.         startProgressbar();
  62.       }
  63.     }
  64.     }
  65.  
  66.     function resetProgressbar() {
  67.     $bar.css({
  68.       width: 0 + '%'
  69.     });
  70.     clearTimeout(tick);
  71.     }
  72.  
  73.     startProgressbar();
  74.  
  75.     $('.slick-next, .slick-prev').click(function() {
  76.     startProgressbar();
  77.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement