I have created a site where users are able to scroll through a gallery using mouse scroll or arrow up/down. It is working like I want it to, and changing one image pr scroll when scrolling with a mouse. But if the user is scrolling with a trackpad it is almost impossible to scroll a single image at a time.
So my question is: Is there a way to check if the user is scrolling by trackpad, and then changing the behavior of the scrolling, so it becomes less sensitive, and thereby easier to scroll a single image at a time?
I am not very good at jquery, my solution so far has been put together from a couple of scripts:
http://jsfiddle.net/MukuMedia/PFjzX/33/
Hope someone can help me :)
I ran into a similar problem with a "section-change" plugin that I created. I ended resolving it with an "animation" variable: the wheel action only works if this variable is set to 'false' and once this is triggered the variable switches to 'true', then I would switch the variable back to 'false' once the animation is completed. Hope this helps!
No, this is not possible. The only solution I can think of is set a limit on the scrolling speed. I'm not going to try and decipher your code but I'd recommend making a
timedOut
variable initialized to zero which is set to one every time you scroll to a new image. Use asetTimeout()
to set it back to zero after, say, 50ms. Before you scroll to a new image, check thistimedOut
variable and only scroll if it's zero. (Make sure you place yoursetTimeout
inside of thetimedOut
check, otherwise it will be constantly called every time the mousewheel moves, which is not what you want.)I found a solution which detects if the user is using a touchpad. It works great and has only two tiny drawbacks.
Firstly it detects the mousescroll after the first fired event, so theres one click with the mousewheel which does nothing. But this is only the first time. Then we can cache the value which leads to the second tiny problem. When the user has a trackpad and a mouse with wheel it detects whatever gets used first. To me those problems are negligible. Here the code
This is pretty much what DC_ suggested. Figured I'd post this since it's an actual implementation.
I found out that the magic number here was 40.
It seems that with the trackpad (probably with the magic mouse too) the delta get increased 40 times.
And it stays that way even if you take back your normal mouse and scroll with it later.
So what I did, using the jquery mousewheel plugin :