This is the configuration I am using to create a slick carousel on my web page:
$('#carousel').slick({
infinite: true,
slidesToShow: 3,
slidesToScroll: 1,
arrows: true,
autoplay: true,
autoplaySpeed: 2000,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 2,
slidesToScroll: 1,
},
},
{
breakpoint: 1008,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
},
},
{
breakpoint: 800,
settings: 'unslick',
},
],
})
It is working the way it is supposed to work except for one thing... when I resize my browser window from width: 1920
to 800
, the carousel unslicks it, and the content is displayed like normal divs.
But then when I increase the width
of the browser window the carousel doesn't recreate it. It remains like HTML div
blocks without carousel.
Any help would be appreciated.
Fully responsive. Scales with its container. Uses CSS3 when available. Fully functional when not.
Breakpoints are the pixel values where Smart Slider changes to show a different layout. For example, you can use breakpoints to make the slider switch to tablet view below 1199px screen width. Breakpoints in Smart Slider based on both the width and height of the browser where the slider displays.
After calling an request, set timeout to initialize slick slider. Do not initialize slick slider at start. Just initialize after an AJAX with timeout. That should work for you.
unslick is a destructor method. Once you unslick, you need to call slick() again to construct carousel.
This is one way to rebuild the carousel after unslick kills it at a breakpoint:
$(window).resize(function () {
$('.js-slider').not('.slick-initialized').slick('resize');
});
$(window).on('orientationchange', function () {
$('.js-slider').not('.slick-initialized').slick('resize');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With