Skip to content

Commit ee4aebc

Browse files
authored
Fix initial zoom level and pan with drag modifier (#557)
1 parent 3ba323e commit ee4aebc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/core.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ export function getZoomLevel(chart) {
152152
let max = 1;
153153
each(chart.scales, function(scale) {
154154
const origRange = getOriginalRange(state, scale.id);
155-
const level = Math.round(origRange / (scale.max - scale.min) * 100) / 100;
156-
min = Math.min(min, level);
157-
max = Math.max(max, level);
155+
if (origRange) {
156+
const level = Math.round(origRange / (scale.max - scale.min) * 100) / 100;
157+
min = Math.min(min, level);
158+
max = Math.max(max, level);
159+
}
158160
});
159161
return min < 1 ? min : max;
160162
}

src/hammer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function createEnabler(chart, state) {
1515
return true;
1616
}
1717
if (!state.panning && event.pointerType === 'mouse' && (
18-
keyNotPressed(getModifierKey(panOptions), srcEvent) || keyPressed(getModifierKey(zoomOptions), srcEvent))
18+
keyNotPressed(getModifierKey(panOptions), srcEvent) || keyPressed(getModifierKey(zoomOptions.drag), srcEvent))
1919
) {
2020
call(panOptions.onPanRejected, [{chart, event}]);
2121
return false;

0 commit comments

Comments
 (0)