graphtoy-plus
graphtoy-plus copied to clipboard
scroll wheel bug in Firefox (fix provided)
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)
Awesome! I'll make that fix thank you!
I just discovered this wasn't a firefox bug, but a firefox + logitech SetPoint plugin (for smooth scrolling) that causes the issue.