Merge pull request #2158 from cavenel/master

Fix wrong center point on pinch zoom
This commit is contained in:
Ian Gilman 2022-05-12 13:54:26 -07:00 committed by GitHub
commit f3f20fd30d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3289,9 +3289,6 @@ function onCanvasPinch( event ) {
if ( gestureSettings.pinchToZoom && if ( gestureSettings.pinchToZoom &&
(!canvasPinchEventArgs.preventDefaultPanAction || !canvasPinchEventArgs.preventDefaultZoomAction) ) { (!canvasPinchEventArgs.preventDefaultPanAction || !canvasPinchEventArgs.preventDefaultZoomAction) ) {
centerPt = this.viewport.pointFromPixel( event.center, true ); centerPt = this.viewport.pointFromPixel( event.center, true );
if ( !canvasPinchEventArgs.preventDefaultZoomAction ) {
this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
}
if ( gestureSettings.zoomToRefPoint && !canvasPinchEventArgs.preventDefaultPanAction ) { if ( gestureSettings.zoomToRefPoint && !canvasPinchEventArgs.preventDefaultPanAction ) {
lastCenterPt = this.viewport.pointFromPixel( event.lastCenter, true ); lastCenterPt = this.viewport.pointFromPixel( event.lastCenter, true );
panByPt = lastCenterPt.minus( centerPt ); panByPt = lastCenterPt.minus( centerPt );
@ -3303,6 +3300,9 @@ function onCanvasPinch( event ) {
} }
this.viewport.panBy(panByPt, true); this.viewport.panBy(panByPt, true);
} }
if ( !canvasPinchEventArgs.preventDefaultZoomAction ) {
this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
}
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
if ( gestureSettings.pinchRotate && !canvasPinchEventArgs.preventDefaultRotateAction ) { if ( gestureSettings.pinchRotate && !canvasPinchEventArgs.preventDefaultRotateAction ) {