-
Notifications
You must be signed in to change notification settings - Fork 494
Normalize scrolling speed for Macbook Trackpads and different browsers. #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thx for the contribution :) I had no idea about these inconsistencies with scrolling handling. I'll browse through it as soon as I'll have some time. |
I just found this and can also comment it's the first thing I noticed. On a macbook trackpad under 10.8.3 the sensitivity is almost inverted, where the less I move my fingers the stronger the scrolling reaction. Glad to hear there might be a solution |
Can someone please give me the buffer output from here: http://jsfiddle.net/3J7f4/2/ for devices/browsers experiencing wrong scrolling speed in Sly? |
This is a single swipe down, which on my macbook pro (2011) trackpad is a scroll down:
|
This is a swipe up
|
This is a very slow swipe down
|
Can someone please test the new wheel delta normalization from commit above? You need to grab the development version from |
The new version still scrolls way too fast on a macbook trackpad in chrome, if I scroll only a bit on my touchpad I immediately reach the end of a 8k pixels page. The difficult part is that macbook trackpads accelerate when you scroll faster so you have to somehow detect that magic... Some examples from your previous fiddle: |
Safari also behaves differently when scrolling: |
Sorry for spamming, but I'm noticing that the scrolling speed affects the speed of the animation and not the range of the scroll. When I scroll slowly it just slowly animates the scoll, but when I scroll quickly the animation speeds up but the range of the scroll stays about the same. So ideally we should not only take the "scrollBy" into account but also the animation speed. |
It was too fast in the first place? May have been useful to mention :) Right now, I'm trying to understand how could your PR fix anything. The d = Math.min(Math.max(d / 2, -1), 1); Which forces the delta to be You than take this value, and if we are not in an item based navigation (i.e. when scroll is controlled by amount of pixels, not items), you use it to multiply the scrollBy option. That also leaves item based navigation scrolling the same. The whole thing can be basically replaced by: if (!itemNav && safari) {
o.scrollBy /= 2;
} Which hardly seems like a fix. And I'm definitely not doing userAgent sniffing. Before the normalization attempt, Sly was scrolling the content by the same amount of pixels/items per one The normalization than scrolls by N times more pixels if it detects N events concatenated, which works as expected in most browsers that behave this way. This obviously makes the matter in affected browsers even worse. If the base delta is You say that the default behavior of this browsers is: distance scrolled per scroll events fired is the same, but only the scroll speed/velocity changes (ref issue #29). This means that if we are interested only in scroll distance, we should ignore the So right now, it seems that the issue is too high frequency of Someone correct me if I'm wrong :) |
Oh, right. That |
I'm going to close this PR and continue in a dedicated issue. |
After playing around with this library I found out that it had the same problem as all scrolling libraries have, it behaves completely different in some browsers and especially with macbook trackpads.
After playing around with the scrolling and attempting to fix it myself I found a working piece of code on stackoverflow (http://stackoverflow.com/a/13650579) which I've tested in IE9, IE10, latest Firefox, latest Chrome and in the latest Safari with a normal wheel-based mouse and a macbook trackpad. It works pretty well in my case, but it could still be that I messed something up as I only tested it in a item based slider and as a scrollbar replacement.
But hey, thought you might like it. And thanks for this amazing thing, sly is great!