From 85d8d9ee3295196405220296e63ba7cee61a3b4d Mon Sep 17 00:00:00 2001 From: "schueffp@mskcc.org" Date: Fri, 16 Mar 2018 11:29:16 +0100 Subject: [PATCH 1/2] Added option zoomToRefPoint for all gestureSettings This is an option for different applications or user preferences: If zoomToRefPoint in a gesture setting is true (default), the zoom is centered at the pointer position. Otherwise, the zoom is centered at the canvas center. --- src/openseadragon.js | 12 ++++++++++++ src/viewer.js | 10 ++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index fd3fe809..d0dbe754 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -314,6 +314,8 @@ * @property {Boolean} [gestureSettingsMouse.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true * then clickToZoom should be set to false to prevent multiple zooms. * @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture + * @property {Boolean} [gestureSettingsMouse.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, + * the zoom is centered at the canvas center. * @property {Boolean} [gestureSettingsMouse.flickEnabled=false] - Enable flick gesture * @property {Number} [gestureSettingsMouse.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) * @property {Number} [gestureSettingsMouse.flickMomentum=0.25] - If flickEnabled is true, the momentum factor for the flick gesture @@ -326,6 +328,8 @@ * @property {Boolean} [gestureSettingsTouch.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true * then clickToZoom should be set to false to prevent multiple zooms. * @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture + * @property {Boolean} [gestureSettingsTouch.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, + * the zoom is centered at the canvas center. * @property {Boolean} [gestureSettingsTouch.flickEnabled=true] - Enable flick gesture * @property {Number} [gestureSettingsTouch.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) * @property {Number} [gestureSettingsTouch.flickMomentum=0.25] - If flickEnabled is true, the momentum factor for the flick gesture @@ -338,6 +342,8 @@ * @property {Boolean} [gestureSettingsPen.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true * then clickToZoom should be set to false to prevent multiple zooms. * @property {Boolean} [gestureSettingsPen.pinchToZoom=false] - Zoom on pinch gesture + * @property {Boolean} [gestureSettingsPan.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, + * the zoom is centered at the canvas center. * @property {Boolean} [gestureSettingsPen.flickEnabled=false] - Enable flick gesture * @property {Number} [gestureSettingsPen.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) * @property {Number} [gestureSettingsPen.flickMomentum=0.25] - If flickEnabled is true, the momentum factor for the flick gesture @@ -350,6 +356,8 @@ * @property {Boolean} [gestureSettingsUnknown.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true * then clickToZoom should be set to false to prevent multiple zooms. * @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture + * @property {Boolean} [gestureSettingsUnknown.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, + * the zoom is centered at the canvas center. * @property {Boolean} [gestureSettingsUnknown.flickEnabled=true] - Enable flick gesture * @property {Number} [gestureSettingsUnknown.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) * @property {Number} [gestureSettingsUnknown.flickMomentum=0.25] - If flickEnabled is true, the momentum factor for the flick gesture @@ -1044,6 +1052,7 @@ function OpenSeadragon( options ){ clickToZoom: true, dblClickToZoom: false, pinchToZoom: false, + zoomToRefPoint: true, flickEnabled: false, flickMinSpeed: 120, flickMomentum: 0.25, @@ -1054,6 +1063,7 @@ function OpenSeadragon( options ){ clickToZoom: false, dblClickToZoom: true, pinchToZoom: true, + zoomToRefPoint: true, flickEnabled: true, flickMinSpeed: 120, flickMomentum: 0.25, @@ -1064,6 +1074,7 @@ function OpenSeadragon( options ){ clickToZoom: true, dblClickToZoom: false, pinchToZoom: false, + zoomToRefPoint: true, flickEnabled: false, flickMinSpeed: 120, flickMomentum: 0.25, @@ -1074,6 +1085,7 @@ function OpenSeadragon( options ){ clickToZoom: false, dblClickToZoom: true, pinchToZoom: true, + zoomToRefPoint: true, flickEnabled: true, flickMinSpeed: 120, flickMomentum: 0.25, diff --git a/src/viewer.js b/src/viewer.js index bffb18ad..341e3d49 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2652,7 +2652,7 @@ function onCanvasClick( event ) { if ( gestureSettings.clickToZoom ) { this.viewport.zoomBy( event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick, - this.viewport.pointFromPixel( event.position, true ) + gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null ); this.viewport.applyConstraints(); } @@ -2691,7 +2691,7 @@ function onCanvasDblClick( event ) { if ( gestureSettings.dblClickToZoom ) { this.viewport.zoomBy( event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick, - this.viewport.pointFromPixel( event.position, true ) + gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null ); this.viewport.applyConstraints(); } @@ -3005,7 +3005,9 @@ function onCanvasPinch( event ) { panByPt.y = 0; } this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true ); - this.viewport.panBy( panByPt, true ); + if ( gestureSettings.zoomToRefPoint ) { + this.viewport.panBy(panByPt, true); + } this.viewport.applyConstraints(); } if ( gestureSettings.pinchRotate ) { @@ -3068,7 +3070,7 @@ function onCanvasScroll( event ) { factor = Math.pow( this.zoomPerScroll, event.scroll ); this.viewport.zoomBy( factor, - this.viewport.pointFromPixel( event.position, true ) + gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null ); this.viewport.applyConstraints(); } From 4889d63534191c67b9e70844d82057ed9a507f23 Mon Sep 17 00:00:00 2001 From: "schueffp@mskcc.org" Date: Fri, 16 Mar 2018 11:44:42 +0100 Subject: [PATCH 2/2] removed trailing spaces error --- src/openseadragon.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index d0dbe754..4cb36dd3 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -314,7 +314,7 @@ * @property {Boolean} [gestureSettingsMouse.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true * then clickToZoom should be set to false to prevent multiple zooms. * @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture - * @property {Boolean} [gestureSettingsMouse.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, + * @property {Boolean} [gestureSettingsMouse.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, * the zoom is centered at the canvas center. * @property {Boolean} [gestureSettingsMouse.flickEnabled=false] - Enable flick gesture * @property {Number} [gestureSettingsMouse.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) @@ -328,7 +328,7 @@ * @property {Boolean} [gestureSettingsTouch.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true * then clickToZoom should be set to false to prevent multiple zooms. * @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture - * @property {Boolean} [gestureSettingsTouch.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, + * @property {Boolean} [gestureSettingsTouch.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, * the zoom is centered at the canvas center. * @property {Boolean} [gestureSettingsTouch.flickEnabled=true] - Enable flick gesture * @property {Number} [gestureSettingsTouch.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) @@ -342,7 +342,7 @@ * @property {Boolean} [gestureSettingsPen.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true * then clickToZoom should be set to false to prevent multiple zooms. * @property {Boolean} [gestureSettingsPen.pinchToZoom=false] - Zoom on pinch gesture - * @property {Boolean} [gestureSettingsPan.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, + * @property {Boolean} [gestureSettingsPan.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, * the zoom is centered at the canvas center. * @property {Boolean} [gestureSettingsPen.flickEnabled=false] - Enable flick gesture * @property {Number} [gestureSettingsPen.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second) @@ -356,7 +356,7 @@ * @property {Boolean} [gestureSettingsUnknown.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true * then clickToZoom should be set to false to prevent multiple zooms. * @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture - * @property {Boolean} [gestureSettingsUnknown.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, + * @property {Boolean} [gestureSettingsUnknown.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, * the zoom is centered at the canvas center. * @property {Boolean} [gestureSettingsUnknown.flickEnabled=true] - Enable flick gesture * @property {Number} [gestureSettingsUnknown.flickMinSpeed=120] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)