P
P
Pit2018-11-24 11:55:29
JavaScript
Pit, 2018-11-24 11:55:29

Scrolling slick slider when clicking on list items?

Hello! I need help, there is a slick slider and there is a regular ul list, you need to make it so that by clicking on the list elements the slider scrolls, and also if the slider itself is scrolled, then the active of the list changes automatically.
5bf91250c6999356164637.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Beliyadm, 2018-11-25
@pit6262

$('.slider_blocks').on('click', 'li', function(){
    var lindex = $(this).index();
    $( ".slider" ).slick('slickGoTo', parseInt(lindex)); // меняем слад на нужный индекс
    $('.slider_blocks li').removeClass('active'); // change class
    $(this).addClass('active');
});

where slider_blocks is the UL class that contains the slider controls LI
AND the reverse control of the list when changing the slide
$('.slider').on('afterChange', function(event, slick, currentSlide, nextSlide){
    var slideIndex = $(this).index();
    $('.slider_blocks li').removeClass('active');
    $('.slider_blocks li').eq(currentSlide).addClass('active')
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question