C
C
Concencuc2021-07-06 14:41:41
JavaScript
Concencuc, 2021-07-06 14:41:41

How to make the touchpad scroll event on a laptop work 1 time?

https://codepen.io/Concencuc/pen/rNmxPPm
Several values ​​are displayed in the console if you scroll with the touchpad. And if you scroll with the mouse, then one value is displayed.
As a result of this, in my script, the slider will scroll several slides at once if you use the touchpad.

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

      if (e.deltaY < 0) {
        $(this).stop().slick('slickPrev');
      } else {
        $(this).stop().slick('slickNext');
      }
    }));

Please tell me how to fix this bug

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vika Marmeladka, 2021-07-06
@homsi959

Try to react not to the scroll. And for touch events
https://developer.mozilla.org/ru/docs/Web/API/Touc...
There is also such a library: https://hammerjs.github.io/
This is a similar question: Is there an API from the touchpad for the web?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question