hamster.js
hamster.js copied to clipboard
using both mouse wheel and trackpad gives inconsistent results
Mixing both mouse wheel and trackpad gives inconsistent results. On the demo page, on rectangle #2:
- scroll using mouse wheel -> gives small deltas, +/- 1 for one wheel movement
- then switching to trackpad (two fingers scrolling on mac) -> gives also small deltas when going slowly
- switching back to mouse wheel -> deltas are now +/- 40
Mac OS X, chrome 35
I'm not able to recreate this using a Macbook Air trackpad and Apple Mouse with Scroll Ball.
The delta is relative to the speed of scrolling, but if I'm careful to keep the speed slow, I'm able to switch from my trackpad to the mouse and back again, whilst retaining +/-1 deltas.
Also in Mac OS X (10.8.5), Chrome 35.
I wonder if the type of mouse (or other hardware variations) makes a difference?
Thanks for having a look. May be related to mouse differences : I am using a non-mac scroll mouse (PC stuff, lenovo). On the other hand, I don't have this issue with jquery-mousewheel (I noticed the issue while converting a project from jQuery to Angular/jqLite).
OK, I've got a PC mouse at home, will check it out and get back to you.
I finally got some time in the home office, and can recreate this issue exactly as described with a Dell mouse. Will investigate further.
Thanks
Any news on this? Thank you :+1:
Sorry for the lack of progress on this, I'm on hols at the moment, will be back in a week or 2.
So it appears that jquery-mousewheel had the same issue, resolved in their 3.1.6 branch. This was a breaking change in their API, from 'event.delta, event.deltaX, event.deltaY' to 'event.deltaX, event.deltaY, event.deltaFactor'. The deltaFactor property accounts for the different scrolling speed/resolutions which are manifest in this issue.
So the task here is to port the latest delta normalisation code from the current stable version of jquery.mousewheel to hamster.js.
+1
What is the state of this issue?
Hello, seems there has been no progress with issue. I am having some problems with wheelevent in the latest Firefox versions, also seems to be issue in IE 11.
The problems seems to be with the deltaY
, which is not set in the event
object. Adding the deltaY
value to object is not full solution https://github.com/monospaced/hamster.js/blob/master/hamster.js#L211.
Hamster(el).wheel(function(event){
console.log(event.deltaY);
});
Ran into this issue too.
Ok, my problem is Safari's inertial scrolling. You do an instant touch gesture, and Safari keeps emitting scroll events for over 800 milliseconds. Total bummer! :(
I ended up conditionally throttling the callback: 1s for Safari, 100ms for non-Safari.
Same issue here. A mouse on OSX would make the scroll super slow while using the trackpad works fine.
I do have the same issue with jquery-mousewheel. If I just use the event.deltaY this is absolutely the same; if I use event.deltaY * event.deltaFactor
then it's much better with the mouse, but not really smooth (and at times really jerky even) with the touchpad. Probably I'm better off using overflow-y magic, but I just wanted to say that jquery-mousewheel didn't really help here.
Still having this issue. How do we normalize this?
@qrpike Don't want to look like a bad guy, but I'd forget about this module as it is not really maintained. I suggest you check the algorithm proposed by Mozilla, here, that's how I could solve the problem: https://developer.mozilla.org/en-US/docs/Web/Events/wheel#Listening_to_this_event_across_browser
You have to check the deltaMode, for example like this.
const deltaY = event.deltaMode === 1
? -event.deltaY * 18
: -event.deltaY