nice lib.
here's my hack for trying to even out scroll speed between browsers when using touchpads:
@@ -945,7 +945,15 @@ EasyPZ.addMode(function (easypz) {
var delta = eventData.event.wheelDelta ? eventData.event.wheelDelta : -1 * eventData.event.deltaY;
var change = delta / Math.abs(delta);
var zoomingIn = change > 0;
- var scale = zoomingIn ? mode.settings.zoomInScaleChange : mode.settings.zoomOutScaleChange;
+ // Only Firefox seems to use the line unit (which we assume to
+ // be 25px), otherwise the delta is already measured in pixels.
+ var scale;
+ if (eventData.event.deltaMode === 1) {
+ scale = zoomingIn ? 0.92 : 1.08;
+ }
+ else {
+ scale = zoomingIn ? 0.98 : 1.02;
+ }
var relativeScale = 1 - scale;
var absScale = Math.abs(relativeScale) * mode.settings.momentumSpeedPercentage;
var scaleSign = sign(relativeScale);
you can probably make it cleaner. but its normalizing the scale between browsers by checking WheelEvent.deltaMode.
see related:
weaveworks/scope#2788
https://github.com/weaveworks/scope/blob/d8ffea47815559ed908dd04f8593408ecb1e5b87/client/app/scripts/utils/zoom-utils.js
https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
also you are doing event handling wrong.
in FF, events are emitted much less frequently than Chrome.
Chrome literally floods with events. You should be _.debounce()ing them.
see also:
https://stackoverflow.com/a/25991510
http://demo.nimius.net/debounce_throttle/
also, you should not be doing the work inside the event callback. the callback should just be setting a few calculation values like delta, and you should have a separate function doing the work at a controlled (probably 12-24fps) frame rate (using requestAnimationFrame(), or setTimeout if you are a savage).
sorry i don't have time to make a PR. hope this helps :)
nice lib.
here's my hack for trying to even out scroll speed between browsers when using touchpads:
you can probably make it cleaner. but its normalizing the scale between browsers by checking
WheelEvent.deltaMode.see related:
weaveworks/scope#2788
https://github.com/weaveworks/scope/blob/d8ffea47815559ed908dd04f8593408ecb1e5b87/client/app/scripts/utils/zoom-utils.js
https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
also you are doing event handling wrong.
in FF, events are emitted much less frequently than Chrome.
Chrome literally floods with events. You should be
_.debounce()ing them.see also:
https://stackoverflow.com/a/25991510
http://demo.nimius.net/debounce_throttle/
also, you should not be doing the work inside the event callback. the callback should just be setting a few calculation values like delta, and you should have a separate function doing the work at a controlled (probably 12-24fps) frame rate (using
requestAnimationFrame(), orsetTimeoutif you are a savage).sorry i don't have time to make a PR. hope this helps :)