Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop autoplay after clicking on dots in slick.js

So, this is code I use for slider:

$('.autoplay').slick({
    slidesToShow: 3,
    slidesToScroll: 1,
    autoplay: true,
    autoplaySpeed: 2000,
    dots: true
});

And I want that after user clicks on any dot, it will disable autoplay. Then I tried this:

$('.autoplay').on('init', function() {
    $('.slick-dots').click(function() {
        $('.autoplay').slick('autoplay', false);
    });
});

But no help. Here is DEMO from jsFiddle. Is this possible with slick.js?

like image 200
debute Avatar asked Jun 07 '16 09:06

debute


People also ask

How do I stop autoplay on slick slider on click?

slick('slickSetOption', 'autoplay', false, false); });

What is carousel in slick?

The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators. Official documentation.


1 Answers

Try this

$('.autoplay').slick({
    slidesToShow: 3,
    slidesToScroll: 1,
    autoplay: true,
    autoplaySpeed: 1000,
    dots: true
});

$('.slick-dots').on('click', function() {
    $('.autoplay').slick('slickPause');
});
like image 181
Vitaly Avatar answered Oct 02 '22 07:10

Vitaly