F
F
freeman02042021-05-16 15:11:23
JavaScript
freeman0204, 2021-05-16 15:11:23

How to scroll through 4 slides in slick and display the number of current slides?

There is a slider with the following settings:

$('.js_slider_cat_js').slick({
        prevArrow: $('.prev_slider'),
        nextArrow: $('.next_slider'),
        centerMode: true,
        centerPadding: '20%',
        infinite: true,
        slidesToShow: 4,
        slidesToScroll: 4,
        speed: 500,
        variableWidth: true,
    });

  var total_1 = $('.js_slider_test .slick-slide:not(.slick-cloned)').length;
    $('.slide_info .total').text(total_1);

    $('.js_slider_test').on('afterChange', function (event, slick, currentSlide, nextSlide) {
        $('.slide_info .current').text(currentSlide + 1);
    });


I found the total number of slides, and now I need to display the current slide. I now have 1 out of 20 displayed. But in fact 4 are active. It should be like this, 4 out of 20, clicked next and already 8 out of 20, etc.
I have slidesToScroll: 4, but it still scrolls one at a time. Maybe it's in centerMode?
The block with the current slide and the total amount is a separate layout for me.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question