I encountered a problem when capturing the wheel event when using the touch mouse. The fact is that in a mouse with a wheel, the wheel is triggered when the threshold is switched (or whatever the scroll pitch is called), and in touch mice, everything is much sadder. Firstly, it is not necessary for the touch mouse to hold your finger on the touchpad so that it continues scrolling, that is, if you have played your finger on the touchpad, the wheel event will still work for a while (or even 7 seconds). All this is done as I understand it to mitigate the scroll for the convenient (pathetic) use of sensory mice.

I will say right away that I have a Microsoft mouse and that the duration of the triggering of the event itself can vary from the mouse itself and from the computer settings (already tested).

The essence of the question is as follows. How to catch or how to distinguish that the event worked at the moment when the finger on the touchpad, and these are not residual calls that the mouse throws out to soften the scroll.

Already tried to write a script to catch all events, the interval of which is 50 milliseconds, but in vain as if for some mice and settings it will ignore extra events for others, or not at all. So you shouldn't rely here for a while.

Maybe there is some property that stores data that will help distinguish a normal wheel from a pseudo wheel.

  • I think not, treat it as if the mouse wheel is lead and half a meter in diameter. Can you distinguish the force applied from inertia? - zb '
  • here the inertial force depends on the computer settings and it may be that the signal about the event is from the touchpad as well as from the pseudo event - Anna Bakurova
  • The browser does not know about the fact that you have a pointer device, it only separates the touch screen (touch) and the mouse. you can easily verify this by writing console.log (e) in your event handler. - zb '
  • Yes, the fact that the event is the same as with the usual one I understood, but as the same sites like this hellomonday.com/home ignore the events from the pointer device - Anna Bakurova
  • and what is the disregard? they have blocking input while scrolling animation is simple. - zb '

1 answer 1

  1. On the event wheel hang counter + =
  2. Set a marker that ignores new wheel events while the current one lasts.
  3. Check at a certain interval whether the counter value has changed. If it has changed - the wheel still happens, if it remains the same - the wheel event is completed, we remove the interval and remove the marker.

Important! The interval should be small, otherwise a wheel from a new user event can get into the counter, and we are only interested in the current one.

https://jsfiddle.net/rafaylik/sLjyyfox/

[] 
  • one
    This event conversion is called "event debouncing" . If I understood the idea correctly. - D-side
  • Seem to be. By the way, for most cases, such an implementation on window.onscroll is sufficient. In my version, the event is localized to a specific element, and onwheel is listened , not onscroll . It can be useful for interfaces without a scrollbar (and / or overflow: hidden ). - Michael Rafaylik