F
F
freeman02042021-06-10 12:54:54
JavaScript
freeman0204, 2021-06-10 12:54:54

How to count slides one at a time while slick is set to slidesToScroll: 4?

Now the slider scrolls 4 slides at a time and naturally counts the scrolling as 1.5, and so on. The buttons on the slick are custom and the block with the output of the number of slides and the current slide are also custom.

Below is one solution but it doesn't always work.

How else can you implement this functionality on a slick? So that when scrolling through 4 slides at a time, write 1/10, 2/10, 3/10, etc.

var total_1 = $('.slider_product_js_tab_2 .slick-slide:not(.slick-cloned)').length / 4;

            $('.wrapper_arrow_tab_2 .total').text(Math.ceil(total_1));
            $('.slider_product_js_tab_2').on('afterChange', function (event, slick, currentSlide, nextSlide) {
                $('.wrapper_arrow_tab_2 .current').text(currentSlide / 4 + 1);
            });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2021-06-10
@freeman0204

Rounding up is needed for odd combinations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question