Files
weave-scope/client/app/scripts/utils/zoom-utils.js
Filip Barl d8ffea4781 Balance timeline zooming sensitivity between Firefox and Chrome (#2788)
* Balanced timeline zooming sensitivity between Firefox and Chrome.

* Organize the wheel delta zooming logic better.
2017-08-07 11:27:12 +02:00

16 lines
507 B
JavaScript

const ZOOM_SENSITIVITY = 0.0025;
const DOM_DELTA_LINE = 1;
// See https://github.com/d3/d3-zoom/blob/807f02c7a5fe496fbd08cc3417b62905a8ce95fa/src/zoom.js
function wheelDelta(ev) {
// Only Firefox seems to use the line unit (which we assume to
// be 25px), otherwise the delta is already measured in pixels.
const unitInPixels = (ev.deltaMode === DOM_DELTA_LINE ? 25 : 1);
return ev.deltaY * unitInPixels * ZOOM_SENSITIVITY;
}
export function zoomFactor(ev) {
return Math.exp(wheelDelta(ev));
}