Great work and great script.
A very quick feature to add as all of the 'variables' are there....It would be good to have a function to call to return the total number of slides in the slider, as I'd like to use this 'onclick' to identify whether more slides need to be added (based on current slide vs total slides in slider).
Hate to be _that_ guy, but what's wrong with using something like this?
jQuery('.slick-slide:not(.slick-cloned)').length
@doot0 you aren't that guy. I just did that in production on a site while using slick lol.
Sorry to be that other guy. How do you implement this to display the slide count?
@justiny you are definitely that other guy. I would do it in the customPaging option method
Damn, now I'll have to hope it helps other guys ; )
Its works for me.
$(".slick").on("init", function(event, slick){
console.log(slick.slideCount);
console.log(slick.currentSlide+1);
});
$(".slick").slick({
arrows: false,
autoplay: true,
dots: true,
infinite: true
});
$(".slick").on("afterChange", function(event, slick, currentSlide){
console.log(currentSlide+1);
});
if you show more then one slide slideCount doesn't work.
var slidesPerPage = 6
$(".slick").on("init", function(event, slick){
maxPages = Math.ceil(slick.slideCount/slidesPerPage);
$(this).find('.slider-paging-number li').append('/ '+maxPages);
});
$(".slick").slick({
slidesToShow: slidesPerPage,
slidesToScroll: slidesPerPage,
arrows: false,
autoplay: true,
dots: true,
infinite: true,
dotsClass: 'slider-paging-number'
});
Most helpful comment
Hate to be _that_ guy, but what's wrong with using something like this?
jQuery('.slick-slide:not(.slick-cloned)').length