Compare commits

...

3 Commits

Author SHA1 Message Date
Ian Gilman
a27b511ad3 Changelog for #2158 2022-05-12 13:55:42 -07:00
Ian Gilman
f3f20fd30d
Merge pull request #2158 from cavenel/master
Fix wrong center point on pinch zoom
2022-05-12 13:54:26 -07:00
Christophe Avenel
f1865c3878
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
2022-05-12 10:45:47 +02:00
2 changed files with 4 additions and 3 deletions

View File

@ -20,6 +20,7 @@ OPENSEADRAGON CHANGELOG
* Now if you pass an error handler into makeAjaxRequest, it doesn't report errors into the console (#2142 @Aiosa) * Now if you pass an error handler into makeAjaxRequest, it doesn't report errors into the console (#2142 @Aiosa)
* Fixed error caused by attaching MouseTracker to the page's document element (#2145 @tdiprima) * Fixed error caused by attaching MouseTracker to the page's document element (#2145 @tdiprima)
* Added fallback and deprecation warning for Viewer.buttons (which got changed to buttonGroup in 3.0.0) (#2153 @devbyjonah) * Added fallback and deprecation warning for Viewer.buttons (which got changed to buttonGroup in 3.0.0) (#2153 @devbyjonah)
* Pinch to zoom now zooms around the center of the pinch, rather than the center of the viewer (#2158 @cavenel)
3.0.0: 3.0.0:

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 ) {