Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use mouse scroll instead of drag in Slick.js?

What's the best way to implement scroll with slick.js so that when you scroll with your mouse, it switches to the next slide? Or is there a setting I am missing?

Here is what I'm referring to, just in case. http://kenwheeler.github.io/slick/

like image 239
migs Avatar asked Oct 01 '17 03:10

migs


People also ask

How do you fix the scrolly jerky?

Mouse scroll wheel jumps can usually be solved by basic troubleshooting techniques like rebooting the computer, cleaning the mouse components, replacing or recharging the mouse batteries, or checking the wireless connection or USB port. The issue can also be resolved by updating corrupt or outdated drivers.

How do you use slick slider Codepen?

You can also link to another Pen here (use the . css URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.

Does slick slider use jQuery?

Slick is a fresh new jQuery plugin for creating fully customizable, responsive and mobile friendly carousels/sliders that work with any html elements.


1 Answers

I little modified previous answer for Mac. Because there scroll triggering multiple times.

var slider = $(".slider-item");
var scrollCount = null;
var scroll= null;

slider
    .slick({
        dots: true
    });

slider.on('wheel', (function(e) {
    e.preventDefault();

    clearTimeout(scroll);
    scroll = setTimeout(function(){scrollCount=0;}, 200);
    if(scrollCount) return 0;
    scrollCount=1;

    if (e.originalEvent.deltaY < 0) {
        $(this).slick('slickNext');
    } else {
        $(this).slick('slickPrev');
    }
}));
like image 161
Maxym Kopych Avatar answered Nov 09 '22 03:11

Maxym Kopych