How to control the trackpad scrolling speed on scrolling a dropdown in js?

26 views Asked by At

While scrolling the time picker using trackpad only one time should scroll at a time. Using mouse scroll it's perfectly working but using trackpad the scrolling speed is too fast. Is it possible to control the trackpad speed in js? enter image description here

1

There are 1 answers

0
Skydrum On

Scrolling is often managed by the browser and operating system, and there's no direct way in JavaScript to adjust trackpad speed.

However, you can try a few techniques to improve scrolling control with the trackpad:

Try this :

dropdown.addEventListener('wheel', function (event) {
    event.preventDefault(); 
    
    
    var delta = event.deltaY || event.detail || event.wheelDelta;
    var scrollAmount = 30;

    dropdown.scrollTop += delta > 0 ? scrollAmount : -scrollAmount;
});