Skip to content
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

Wheel Scrolling is to slow in FireFox in conjunction with jquery-mousewheel plugin #2823

Open
raggzy opened this issue Jun 1, 2017 · 5 comments

Comments

@raggzy
Copy link

raggzy commented Jun 1, 2017

Is reproduced when using in conjunction with jquery-mousewheel plugin.

See https://jsfiddle.net/4Lba076o/

In Chrome scrolling is OK.
In Firefox it's very slow (1px).

Basically, mouse wheel behavior is not utilizing event.deltaFactor (which is non-standard however).
In Firefox jquery-mousewheel transforms event from {deltaY: -42} to {deltaY: -1, deltaFactor: 42}

@storeman
Copy link

storeman commented Sep 7, 2017

I had the same issue, but it has nothing to do with mousewheel i think.

I found that Firefox uses a deltaMode of 1, which is scroll per line. So a delta of 3 means 3 lines instead of pixels.

I hacked this into the chosen.jquery.js and it made scrolling a lot faster:

Chosen.prototype.search_results_mousewheel = function(evt) {
     /** Added the factor var and set it's value to 16 when scrolling is line scrolling */
      var delta, factor;
      if (evt.originalEvent) {
        factor = evt.originalEvent.deltaMode === 1 /** DOM_DELTA_LINE */ ? 16 : 1;
        delta = factor * evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
      }
      
      if (delta != null) {
        evt.preventDefault();
        if (evt.type === 'DOMMouseScroll') {
          delta = delta * 40;
        }
        return this.search_results.scrollTop(delta + this.search_results.scrollTop());
      }
    };

@gibus
Copy link

gibus commented Dec 4, 2017

Patch proposed by storman works perfectly for us. Is it planned to be published in a future release?

@stof
Copy link
Collaborator

stof commented Dec 4, 2017

@storeman can you open a pull request with your patch ?

@storeman
Copy link

storeman commented Jan 26, 2018

I don't know coffeescript or how to compile/test it with grunt. I've made a fix which i think should work, but I'm unable to test is, so I don't want to create a pull request. My fix in coffeescript can be found here:
https://github.com/tioga-tours/chosen/tree/faster-firefox-scroll

@raggzy
Copy link
Author

raggzy commented Jan 27, 2018

@storeman
Actually it has direct connection to jquery mousewheel, because if you have both plugins, jquery mousewheel transforms mouse events like I mentioned. Without jquery mousewheel scroll behavior is just fine in FF.

So how i fixed that without modifying source code of both plugins - i just do $(..).unmousewheel() in places for each i register .chosen(); One could write simple plugin for that :)

If fixing that in the way you did here
factor = evt.originalEvent.deltaMode === 1 /** DOM_DELTA_LINE */ ? 16 : 1;
then i'd change it to
factor = evt.originalEvent.deltaFactor || 1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants