Pinch to zoom and wheel zoom work the same way (#3752)

This commit is contained in:
Shefali Joshi 2021-03-12 12:22:22 -08:00 committed by GitHub
parent 74a516aa9e
commit 325f2c4860
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -413,6 +413,21 @@ define([
return;
}
const isPinchToZoom = event.ctrlKey === true;
let isZoomIn = event.wheelDelta < 0;
let isZoomOut = event.wheelDelta >= 0;
//Flip the zoom direction if this is pinch to zoom
if (isPinchToZoom) {
if (isZoomIn === true) {
isZoomOut = true;
isZoomIn = false;
} else if (isZoomOut === true) {
isZoomIn = true;
isZoomOut = false;
}
}
let xDisplayRange = this.$scope.xAxis.get('displayRange');
let yDisplayRange = this.$scope.yAxis.get('displayRange');
@ -445,7 +460,7 @@ define([
};
}
if (event.wheelDelta < 0) {
if (isZoomIn) {
this.$scope.xAxis.set('displayRange', {
min: xDisplayRange.min + ((xAxisDist * ZOOM_AMT) * xAxisMinDist),
@ -456,7 +471,7 @@ define([
min: yDisplayRange.min + ((yAxisDist * ZOOM_AMT) * yAxisMinDist),
max: yDisplayRange.max - ((yAxisDist * ZOOM_AMT) * yAxisMaxDist)
});
} else if (event.wheelDelta >= 0) {
} else if (isZoomOut) {
this.$scope.xAxis.set('displayRange', {
min: xDisplayRange.min - ((xAxisDist * ZOOM_AMT) * xAxisMinDist),