mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Fix wrong center point on touch zoom
When doing pinch to zoom, we need to do pan first and then zoom, so that the center point is correct. Otherwise, the pan will computed on the unzoomed coordinates, giving an impression of zooming toward the center
This commit is contained in:
parent
165aaebd4c
commit
f1865c3878
@ -3289,9 +3289,6 @@ function onCanvasPinch( event ) {
|
||||
if ( gestureSettings.pinchToZoom &&
|
||||
(!canvasPinchEventArgs.preventDefaultPanAction || !canvasPinchEventArgs.preventDefaultZoomAction) ) {
|
||||
centerPt = this.viewport.pointFromPixel( event.center, true );
|
||||
if ( !canvasPinchEventArgs.preventDefaultZoomAction ) {
|
||||
this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
|
||||
}
|
||||
if ( gestureSettings.zoomToRefPoint && !canvasPinchEventArgs.preventDefaultPanAction ) {
|
||||
lastCenterPt = this.viewport.pointFromPixel( event.lastCenter, true );
|
||||
panByPt = lastCenterPt.minus( centerPt );
|
||||
@ -3303,6 +3300,9 @@ function onCanvasPinch( event ) {
|
||||
}
|
||||
this.viewport.panBy(panByPt, true);
|
||||
}
|
||||
if ( !canvasPinchEventArgs.preventDefaultZoomAction ) {
|
||||
this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
|
||||
}
|
||||
this.viewport.applyConstraints();
|
||||
}
|
||||
if ( gestureSettings.pinchRotate && !canvasPinchEventArgs.preventDefaultRotateAction ) {
|
||||
|
Loading…
Reference in New Issue
Block a user