Skip to content

Commit

Permalink
Fix initial zoom level and pan with drag modifier (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle authored Jul 1, 2021
1 parent 3ba323e commit ee4aebc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ export function getZoomLevel(chart) {
let max = 1;
each(chart.scales, function(scale) {
const origRange = getOriginalRange(state, scale.id);
const level = Math.round(origRange / (scale.max - scale.min) * 100) / 100;
min = Math.min(min, level);
max = Math.max(max, level);
if (origRange) {
const level = Math.round(origRange / (scale.max - scale.min) * 100) / 100;
min = Math.min(min, level);
max = Math.max(max, level);
}
});
return min < 1 ? min : max;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hammer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function createEnabler(chart, state) {
return true;
}
if (!state.panning && event.pointerType === 'mouse' && (
keyNotPressed(getModifierKey(panOptions), srcEvent) || keyPressed(getModifierKey(zoomOptions), srcEvent))
keyNotPressed(getModifierKey(panOptions), srcEvent) || keyPressed(getModifierKey(zoomOptions.drag), srcEvent))
) {
call(panOptions.onPanRejected, [{chart, event}]);
return false;
Expand Down

0 comments on commit ee4aebc

Please sign in to comment.