hamster.js icon indicating copy to clipboard operation
hamster.js copied to clipboard

using both mouse wheel and trackpad gives inconsistent results

Open r3mi opened this issue 10 years ago • 17 comments

Mixing both mouse wheel and trackpad gives inconsistent results. On the demo page, on rectangle #2:

  1. scroll using mouse wheel -> gives small deltas, +/- 1 for one wheel movement
  2. then switching to trackpad (two fingers scrolling on mac) -> gives also small deltas when going slowly
  3. switching back to mouse wheel -> deltas are now +/- 40

Mac OS X, chrome 35

r3mi avatar May 27 '14 20:05 r3mi

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?

monospaced avatar May 29 '14 09:05 monospaced

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).

r3mi avatar May 29 '14 09:05 r3mi

OK, I've got a PC mouse at home, will check it out and get back to you.

monospaced avatar May 29 '14 09:05 monospaced

I finally got some time in the home office, and can recreate this issue exactly as described with a Dell mouse. Will investigate further.

monospaced avatar Jun 12 '14 07:06 monospaced

Thanks

r3mi avatar Jun 12 '14 17:06 r3mi

Any news on this? Thank you :+1:

juanpujol avatar Jul 10 '14 18:07 juanpujol

Sorry for the lack of progress on this, I'm on hols at the moment, will be back in a week or 2.

monospaced avatar Jul 11 '14 18:07 monospaced

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.

monospaced avatar Aug 20 '14 15:08 monospaced

+1

andyperlitch avatar Oct 09 '14 20:10 andyperlitch

What is the state of this issue?

DavidBM avatar Mar 25 '15 15:03 DavidBM

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);
});

riston avatar May 12 '15 08:05 riston

Ran into this issue too.

lolmaus avatar Jul 27 '15 11:07 lolmaus

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.

lolmaus avatar Jul 27 '15 14:07 lolmaus

Same issue here. A mouse on OSX would make the scroll super slow while using the trackpad works fine.

AoDev avatar Feb 26 '16 15:02 AoDev

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.

szkrd avatar Mar 23 '16 09:03 szkrd

Still having this issue. How do we normalize this?

qrpike avatar Aug 25 '16 11:08 qrpike

@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

AoDev avatar Aug 25 '16 13:08 AoDev