graphtoy-plus icon indicating copy to clipboard operation
graphtoy-plus copied to clipboard

scroll wheel bug in Firefox (fix provided)

Open brainexcerpts opened this issue 2 years ago • 2 comments

There is a bug in Firefox (Chrome works fine) where you can't "scroll in" (but only "scroll out") the graph. The fix is simple (from the original js project; I don't know where it is in graphToy-plus but since it shares the same issue the fix is likely the same):

  // graphtoy.js 
  function iMouseWheel(e)
  {
        if(!e) e = window.event;
        const sfactor = 1.1;


        if( e.deltaY === undefined) return; // Just add this line

        const scale = (e.deltaY<0 || e.wheelDelta>0) ? 1.0/sfactor : sfactor;
        e.preventDefault();
        mRa = mRa * scale;
        if( mPaused ) iDraw();
  }

Explanation: For some reason "scrolling in" generates 2 counter interacting events:

  • A 1st event where e.deltaY and e.wheelDelta are undefined this produces a scale = 1.1
  • A 2nd event with the proper deltaY producing a scale = 0.9 Thus, discarding undefined events fix the issue. (locally tested in Firerox and Chrome)

brainexcerpts avatar Feb 08 '23 02:02 brainexcerpts

Awesome! I'll make that fix thank you!

csprance avatar Feb 08 '23 13:02 csprance

I just discovered this wasn't a firefox bug, but a firefox + logitech SetPoint plugin (for smooth scrolling) that causes the issue.

brainexcerpts avatar Feb 09 '23 05:02 brainexcerpts