Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Fix Issue #577 - Scrolling way too slow in Firefox #752

Merged
merged 1 commit into from
Sep 19, 2014

Conversation

BryanCrow
Copy link
Contributor

This ensures that scroll speed is normal (instead of painfully slow) in the latest versions of Firefox

This ensures that scroll speed is normal (instead of painfully slow) in the latest versions of Firefox
@BryanCrow
Copy link
Contributor Author

I did some reading up to verify this fix (I posted this comment in the original issue, #577, but wanted to post here too to simplify the decision on whether to use this fix, or to come up with your own).

Basically in Firefox, the scroll event can come with a deltaMode for pixels (0), lines (1), as in lines of text, or pages (2). The event comes through with different modes for different people, depending on the OS / Mouse combo. Details here: https://developer.mozilla.org/en-US/docs/Web/Events/wheel#The_deltaMode_value

When the event comes in with a deltaMode of lines (1), the typical system default number of lines of text to scroll per mouse-wheel click is 3 (at least that is the case in Windows). That said, if someone changes that value, chances are they prefer slower or faster scrolling so it's a good value to multiply by.

So, if we treat the delta we recieve of "3" as a pixel value instead of line value (the issue at hand here), we end up getting a very very slow scrolling speed. Hence the fix is to multiply the line value by the mouseWheelSpeed option, when the deltaMode of the event comes in as 1 (DOM_DELTA_LINE). With the default mouseWheelSpeed of 20, that will scroll 60px per wheel click. I'm not sure if a standard pixel amount per wheel click is desired, but if so, you can tweak the multiplier accordingly before applying this patch.

Note that when scrolling very fast, you'll receive a multiple of the system default number of lines to scroll in some of the wheel events (as if it queues them up and fires them less often). Ex: a flick of my mouse wheel gave me the following deltas: 3, 3, 3, 6, 9, 15, 6, 3, 3, 3, 3. Still, I believe amusing 3 to be a single click, you should multiply the delta by whatever value is needed in order to get the desired, consistent scroll speed. The other option one could considder would be to ignore the delta value, and just hard-code the multiplier based on if it's negative or positive. The problem with this is that precision trackpads (new in windows 8.1, and used by Microsoft's Surface tablets) will give you fractions of a line to scroll in each event (and far more events). So again, a multiplier is ideal.

More trial and error discussion here:
http://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line

...and here you can see Mozilla is not going to change this line-based scrolling behavior, so I believe this is a safe change to make and not one that will break in future versions of Firefox):
https://bugzilla.mozilla.org/show_bug.cgi?id=943034

@zowers
Copy link

zowers commented Aug 27, 2014

when the fix is going to be merged?

@cubiq cubiq merged commit 3480247 into cubiq:master Sep 19, 2014
@BryanCrow BryanCrow deleted the patch-1 branch September 23, 2014 22:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants