esnet / react-timeseries-charts

Declarative and modular timeseries charting components for React
http://software.es.net/react-timeseries-charts
Other
861 stars 284 forks source link

Check for Firefox and, in that case, scroll faster in charts #385

Open dirkdevriendt opened 5 years ago

dirkdevriendt commented 5 years ago

Fixes https://github.com/esnet/react-timeseries-charts/issues/302 Reference for Firefox check: https://stackoverflow.com/a/9851769

jdugan1024 commented 5 years ago

Is there any way to make this less Firefox dependent? Is there a more general fix to this problem? I'm not too excited about adding fixes that only address the issue in a single browser.

In other words is there a standard way to detect that scrolling will be slow instead of saying "oh, it's firefox let's scroll faster". In the future if Firefox updates its behavior here then we'll be compensating for an issue that doesn't exist any longer and will create a new bug to fix.

That said this is the real world and there may not be a cleaner fix.

jdugan1024 commented 5 years ago

Also, thanks for looking into this, it is appreciated!

dirkdevriendt commented 5 years ago

I just did this quick fix in the same vain as the hard coded compensation that was already there, but apparently there is a more generic way in the form of -sadly, slightly inconsistent/magical- mouse scroll event properties (e.g. wheelDelta and deltaMode).

This SO question: https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers points to a number of solutions, such as this Fiddle: http://jsfiddle.net/uNeBr/ or this Facebook code: https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js which seems to have inspired this library: https://www.npmjs.com/package/normalize-wheel

To clarify a bit, my understanding is that deltaMode (https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode) defines if the browser measures scrolling in pixels/lines/pages (which is the big -20X- difference to account for), while wheelDelta/deltaX and friends seem to allow for "calibration" differences.

hp8wvvvgnj6asjm7 commented 3 years ago

can't it be merged? pls