by drakinite » Fri Nov 13, 2020 12:02 am
So it looks like it's basically impossible to
unequivocally tell touchpad input apart from mouse input, so my hope of having a scroll bar that logically matches the direction of finger movement is (probably) down the drain.
https://stackoverflow.com/questions/107 ... javascript
However, the same stackoverflow thread shows some logic for detecting (and ignoring) a high amount of concurrent mousewheel events, which denote a trackpad. Detecting and ignoring the repeated mousewheel events could help to prevent the wild up-and-down flicking of the volume bar.
You know... Since touchpads already have great precision drivers, why don't we just make the volume slider go in steps of 1 instead of 5 when it's being controlled by a touchpad? This would be pretty easy in theory. The scroller seems to calculate the delta by dividing the wheelDelta by 120, then multiplying by the step value.
In the volume slider's case, you could check if wheelDelta is less than, say, 60 (They seem to be pretty low unless you scroll pretty fast), then moving it in steps of 1-5, depending on the value. It would also probably work if it's floored to 1, but it wouldn't be as smooth-feeling.
Edit: I just made a prototype in slider.mouseWheelHandler that does that last bit (but without the multi-event rejection), and it honestly works decently. It might break other sliders, I'm not sure, but for the volume it's quite nice already.
So it looks like it's basically impossible to [i]unequivocally [/i]tell touchpad input apart from mouse input, so my hope of having a scroll bar that logically matches the direction of finger movement is (probably) down the drain.
https://stackoverflow.com/questions/10744645/detect-touchpad-vs-mouse-in-javascript
However, the same stackoverflow thread shows some logic for detecting (and ignoring) a high amount of concurrent mousewheel events, which denote a trackpad. Detecting and ignoring the repeated mousewheel events could help to prevent the wild up-and-down flicking of the volume bar.
You know... Since touchpads already have great precision drivers, why don't we just make the volume slider go in steps of 1 instead of 5 when it's being controlled by a touchpad? This would be pretty easy in theory. The scroller seems to calculate the delta by dividing the wheelDelta by 120, then multiplying by the step value.
In the volume slider's case, you could check if wheelDelta is less than, say, 60 (They seem to be pretty low unless you scroll pretty fast), then moving it in steps of 1-5, depending on the value. It would also probably work if it's floored to 1, but it wouldn't be as smooth-feeling.
Edit: I just made a prototype in slider.mouseWheelHandler that does that last bit (but without the multi-event rejection), and it honestly works decently. It might break other sliders, I'm not sure, but for the volume it's quite nice already.