M
M
Marian Vitak2019-08-03 19:21:44
Bootstrap
Marian Vitak, 2019-08-03 19:21:44

Why does a bug appear in the slider when adding responsive?

Hello. Please tell me why a bug appears in the slider when adding responsive? If you remove the adaptation in the slider, then everything works.
You can see it here , the slider is placed at the top of the page in the accordion.
I am attaching the code:

$('.works-slider').slick({
    slidesToShow: 2,
    slidesToScroll: 2,
    fade: false,
    arrows: true,
    dots: false,
    swipe: true,
    responsive: [
        {
            breakpoint: 576,
            settings: {
                slidesToShow: 1,
                slidesToScroll: 1,
            }
        }
    ]
});

$('.collapse__content').on('shown.bs.collapse', function () {
    $('.works-slider').slick('reinit');
});

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Marian, 2019-08-03
Vitak

I found the reason. When opening and closing the accordion, the slider code is duplicated. It remains to figure out how to fix it.

G
gretyl007, 2019-08-03
@gretyl007

Try this:
if (window.innerWidth <= 576) {
$('.works-slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
});
}

E
ed, 2019-08-03
@Screenager

try like this

$('.works-slider').not('.slick-initialized').slick({
    slidesToShow: 2,
    slidesToScroll: 2,
    fade: false,
    arrows: true,
    dots: false,
    swipe: true,
    responsive: [
        {
            breakpoint: 576,
            settings: {
                slidesToShow: 1,
                slidesToScroll: 1,
            }
        }
    ]
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question