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.
This commit is contained in:
schueffp@mskcc.org 2018-03-16 11:29:16 +01:00
parent 251ab23cc0
commit 85d8d9ee32
2 changed files with 18 additions and 4 deletions

View File

@ -314,6 +314,8 @@
* @property {Boolean} [gestureSettingsMouse.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true * @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. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture * @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 {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.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 * @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 * @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. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture * @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 {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.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 * @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 * @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. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsPen.pinchToZoom=false] - Zoom on pinch gesture * @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 {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.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 * @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 * @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. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture * @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 {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.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 * @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, clickToZoom: true,
dblClickToZoom: false, dblClickToZoom: false,
pinchToZoom: false, pinchToZoom: false,
zoomToRefPoint: true,
flickEnabled: false, flickEnabled: false,
flickMinSpeed: 120, flickMinSpeed: 120,
flickMomentum: 0.25, flickMomentum: 0.25,
@ -1054,6 +1063,7 @@ function OpenSeadragon( options ){
clickToZoom: false, clickToZoom: false,
dblClickToZoom: true, dblClickToZoom: true,
pinchToZoom: true, pinchToZoom: true,
zoomToRefPoint: true,
flickEnabled: true, flickEnabled: true,
flickMinSpeed: 120, flickMinSpeed: 120,
flickMomentum: 0.25, flickMomentum: 0.25,
@ -1064,6 +1074,7 @@ function OpenSeadragon( options ){
clickToZoom: true, clickToZoom: true,
dblClickToZoom: false, dblClickToZoom: false,
pinchToZoom: false, pinchToZoom: false,
zoomToRefPoint: true,
flickEnabled: false, flickEnabled: false,
flickMinSpeed: 120, flickMinSpeed: 120,
flickMomentum: 0.25, flickMomentum: 0.25,
@ -1074,6 +1085,7 @@ function OpenSeadragon( options ){
clickToZoom: false, clickToZoom: false,
dblClickToZoom: true, dblClickToZoom: true,
pinchToZoom: true, pinchToZoom: true,
zoomToRefPoint: true,
flickEnabled: true, flickEnabled: true,
flickMinSpeed: 120, flickMinSpeed: 120,
flickMomentum: 0.25, flickMomentum: 0.25,

View File

@ -2652,7 +2652,7 @@ function onCanvasClick( event ) {
if ( gestureSettings.clickToZoom ) { if ( gestureSettings.clickToZoom ) {
this.viewport.zoomBy( this.viewport.zoomBy(
event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick, 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(); this.viewport.applyConstraints();
} }
@ -2691,7 +2691,7 @@ function onCanvasDblClick( event ) {
if ( gestureSettings.dblClickToZoom ) { if ( gestureSettings.dblClickToZoom ) {
this.viewport.zoomBy( this.viewport.zoomBy(
event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick, 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(); this.viewport.applyConstraints();
} }
@ -3005,7 +3005,9 @@ function onCanvasPinch( event ) {
panByPt.y = 0; panByPt.y = 0;
} }
this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true ); this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
if ( gestureSettings.zoomToRefPoint ) {
this.viewport.panBy(panByPt, true); this.viewport.panBy(panByPt, true);
}
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
if ( gestureSettings.pinchRotate ) { if ( gestureSettings.pinchRotate ) {
@ -3068,7 +3070,7 @@ function onCanvasScroll( event ) {
factor = Math.pow( this.zoomPerScroll, event.scroll ); factor = Math.pow( this.zoomPerScroll, event.scroll );
this.viewport.zoomBy( this.viewport.zoomBy(
factor, factor,
this.viewport.pointFromPixel( event.position, true ) gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
); );
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }