K
K
kryamk2021-04-04 11:32:03
css
kryamk, 2021-04-04 11:32:03

Slick slider, twitching when adaptive?

Autoplay with a smooth shift, a kind of running line.
When the window is resized, when the slider is rebuilt to a different number of slides, some jumps appear.
I tried to somehow reinitialize the slider, but even did not help

$(window).on('resize', function() {
  // $('.slider').slick('resize');
  // $('.slider').slick('reinit');
  $('.slider').slick('setPosition');
});


Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kryamk, 2021-04-05
@kryamk

Well, here's a working solution: at the end of the window resize, destroy and create this slider again

function resizedw(){
  $('.slider').slick('unslick');
  $('.slider').slick({
    slidesToShow: 3,
    arrows: true,
    dots: true,
    speed: 5000,
    autoplay: true,
    pauseOnHover: false,
    pauseOnFocus: false,
    cssEase: 'linear', 
    autoplaySpeed: 0,
    customPaging: function() {
      return ''
    },
    responsive: [
    {
      breakpoint: 900,
      settings: {
        slidesToShow: 2,
      }
    },
    {
      breakpoint: 500,
      settings: {
        slidesToShow: 1
      }
    }
    ]
  });
}
let doit;
window.onresize = function(){
  clearTimeout(doit);
  doit = setTimeout(resizedw, 1000);
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question