Search code examples
javascriptcarouselresponsivebreakpointsslick.js

Slick Carousel get current slidesToShow depending on breakpoints


I use the kenwheeler/slick Carousel and i want to take the settings i put. I want to get the attribute slidesToShow. I try this way because of some breakpoints i put also and affects the value of the property above. The easy way is to get the settings object and check for the value of this property. Does anybody knows how to get any attribute of the Slick Settings on demand somehow like:

$('#slickCarouselId').attritubeName 

Thanks ...


Solution

  • If I understand correctly you need

    // get
    let slides = $('#slickCarouselId').slick('slickGetOption', 'slidesToShow');
    // set
    $('#slickCarouselId').slick('slickSetOption', 'slidesToShow', 2, true);
    

    Last argument is passed to refresh UI