Hello!
I use slick slider, it has the rows property, which is needed at one resolution.
As a result, when this property starts to work, the splinter breaks the block into separate blocks and everything breaks down.
I decided to go another way, I’ve put the script

var width = window.innerWidth || document.body.clientWidth; var $slick = $('.js-slider-gift'); function initSlick() { if(width < 960) { if ($slick.hasClass('slick-initialized')) { $slick.slick('unslick'); }; $slick.slick({ slidesToShow: 1, slidesToScroll: 1, infinite: false, mobileFirst: true, arrows: false, variableWidth: true, responsive: [ { breakpoint: 599, settings: { slidesToShow: 2 } } ] }); }; if (width >= 960) { $slick.slick({ rows: 2, slidesToShow: 3, slidesToScroll: 3, arrows: true, infinite: false, dots: false, prevArrow: '<a href="javascript:void();" class="b-product-carousel-gift__arrow b-product-carousel-gift__arrow--prev carousel-control left"></a>', nextArrow: '<a href="javascript:void();" class="b-product-carousel-gift__arrow b-product-carousel-gift__arrow--next carousel-control right"></a>', responsive: [ { breakpoint: 1300, settings: { rows: 2, slidesToShow: 2, slidesToScroll: 2, } } ] }); }; }; $( window ).resize(function() { initSlick(); }); $(document).ready(function() { initSlick(); }); 

I decided to make unslick, but the trouble is that when resizing, the slider is not rebuilt. I can not understand how to do unslick first, and then start again. Responsive slick mode does not work. There just breaks the layout.

    1 answer 1

    Maybe so ?

     $(document).ready(function() { initSlick(); $( window ).on('resize',function() { initSlick(); }); }); 

    that is, each time you resize a window, you call your initialization function again.

    • No, it also works. - drtvader
    • @drtvader if possible, insert a working example for clarity (html + js + img) Maybe you have another problem - Arsen
    • when resize you want to change the values ​​slidesToShow: 1, slidesToScroll: 1,? - Arsen
    • When resizing, you need to change the rows. Less than 960 rows no. - drtvader
    • YES I tried to add to the sandbox. Somehow it does not start. - drtvader