Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
simplify scale factor logic
Browse files Browse the repository at this point in the history
  • Loading branch information
boygirl committed Feb 5, 2017
1 parent 8454fa2 commit b90d886
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/components/containers/zoom-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const Helpers = {
}
},

onWheel(evt, targetProps, eventKey, ctx) { // eslint-disable-line max-params, max-statements
onWheel(evt, targetProps, eventKey, ctx) { // eslint-disable-line max-params
if (!targetProps.allowZoom) {
return {};
}
Expand All @@ -141,10 +141,9 @@ const Helpers = {
const lastDomain = targetProps.currentDomain || zoomDomain || originalDomain;
const {x} = lastDomain;
const xBounds = originalDomain.x;
const delta = evt.deltaY / 300; // TODO: Check scale factor
const maxDelta = delta > 0 ? 0.75 : -0.75; // TODO: Check max scale factor
const factor = Math.abs(delta) > 1 ? 1 + maxDelta : 1 + delta;
const nextXDomain = this.scale(x, xBounds, factor);
const sign = evt.deltaY > 0 ? 1 : -1;
const delta = Math.min(Math.abs(evt.deltaY / 300), 0.75); // TODO: Check scale factor
const nextXDomain = this.scale(x, xBounds, 1 + sign * delta);
const currentDomain = { x: nextXDomain, y: originalDomain.y };
const resumeAnimation = this.handleAnimation(ctx);
if (isFunction(onDomainChange)) {
Expand Down

0 comments on commit b90d886

Please sign in to comment.