Z
Z
zwezew2018-02-28 17:59:40
JavaScript
zwezew, 2018-02-28 17:59:40

How to display current slide number in slick?

How to display current slide number in slick?
Tried to do so

slider.on('beforeChange', function(event, slick, currentSlide, nextSlide){
      console.log(currentSlide);
    });


But the output is strange - for example, I scroll the slider forward, the indexes 0, 1, 2 go, I press back - 3 goes and the next time I click on "back" 2 returns.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-02-28
@zwezew

Use afterChange instead of beforeChange. Or nextSlide instead of currentSlide. Because the currentSlide in beforeChange is the one you're leaving from, i.e. you're now displaying the slide number one step late.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question