Skip to content

Instantly share code, notes, and snippets.

@Korveld
Created September 10, 2020 09:53
Show Gist options
  • Select an option

  • Save Korveld/ca9335b0da34b3c31f4ff26bb7828993 to your computer and use it in GitHub Desktop.

Select an option

Save Korveld/ca9335b0da34b3c31f4ff26bb7828993 to your computer and use it in GitHub Desktop.
Slick slider count slides
// If slides to show more than one
$('.compare__items-row').on('init reInit afterChange', function(event, slick, currentSlide, nextSlide) {
var i = (currentSlide ? currentSlide : 0) + 1
var slidesToShow = slick.slickGetOption('slidesToShow')
var curPage = parseInt((i-1)/slidesToShow) + 1
var lastPage = parseInt((slick.slideCount-1)/slidesToShow) + 1
$('.compare__slider-info--current').text(curPage)
$('.compare__slider-info--all').text(lastPage)
})
// else
var $status = $('.compare__slider-info')
var $slickElement = $('.compare__items-row')
$slickElement.on('init reInit afterChange', function(event, slick, currentSlide, nextSlide){
var i = (currentSlide ? currentSlide : 0)
if (i === 0) var i = 1
$status.text(i + '-' + slick.slideCount / 2)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment