Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Slick carousel - Disable mousewheel gesture when on last slide

I have a vertical slick.js carousel and I have some custom javaScript to handle mousewheel scrolling, I would like to disable this when the user gets to the last slide.

Some example code.

    $(".slick").slick({
      adaptiveHeight: true,
      vertical: true,
      verticalSwiping: true,
      autoPlay: false,
      infinite: false,
      useCSS: false,
      slidesToShow: 1,
      slidesToScroll: 1,
      dots: false,
      arrows: false,
    });

    let blocked = false;
    let blockTimeout = null;
    let prevDeltaY = 0;

    // Handling mouse wheel action.
    $(".slick").on("mousewheel DOMMouseScroll wheel", function (e) {
      let deltaY = e.originalEvent.deltaY;
      e.preventDefault();
      e.stopPropagation();

      clearTimeout(blockTimeout);
      blockTimeout = setTimeout(function () {
        blocked = false;
      }, 100);

      if (
        (deltaY > 0 && deltaY > prevDeltaY) ||
        (deltaY < 0 && deltaY < prevDeltaY) ||
        !blocked
      ) {
        blocked = true;
        prevDeltaY = deltaY;

        if (deltaY > 0) {
          $(this).slick("slickNext");
        } else {
          $(this).slick("slickPrev");
        }
      }
    });

    $(".slick").on("afterChange", function (event, slick, currentSlide) {
      console.log(slick, currentSlide);
      if (slick.$slides.length - 1 == currentSlide) {
        console.log("I am at the Last slide");
      }
    });

I think this is something I should do in the afterChange function, any recommendations?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!