This commit is contained in:
Hamza Tatheer 2022-11-03 23:55:35 +05:00
parent e4d9dcdd03
commit fccab2da56
2 changed files with 35 additions and 8 deletions

View File

@ -344,7 +344,6 @@
* @property {Boolean} [gestureSettingsMouse.dblClickDragToZoom=false] - Zoom on dragging through
* double-click gesture ( single click and next click to drag). 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.
@ -360,6 +359,10 @@
* @property {Boolean} [gestureSettingsTouch.clickToZoom=false] - Zoom on click gesture
* @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.dblClickDragToZoom=true] - Zoom on dragging through
* double-click gesture ( single click and next click to drag). 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.
@ -390,6 +393,9 @@
* @property {Boolean} [gestureSettingsUnknown.clickToZoom=false] - Zoom on click gesture
* @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.dblClickDragToZoom=false] - Zoom on dragging through
* double-click gesture ( single click and next click to drag). 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.
@ -404,6 +410,9 @@
* @property {Number} [zoomPerScroll=1.2]
* The "zoom distance" per mouse scroll or touch pinch. <em><strong>Note:</strong> Setting this to 1.0 effectively disables the mouse-wheel zoom feature (also see gestureSettings[Mouse|Touch|Pen].scrollToZoom}).</em>
*
* @property {Number} [zoomPerDblClickDrag=1.2]
* The "zoom distance" per mouse drag.
*
* @property {Number} [zoomPerSecond=1.0]
* Sets the zoom amount per second when zoomIn/zoomOut buttons are pressed and held.
* The value is a factor of the current zoom, so 1.0 (the default) disables zooming when the zoomIn/zoomOut buttons
@ -1246,7 +1255,7 @@ function OpenSeadragon( options ){
scrollToZoom: false,
clickToZoom: false,
dblClickToZoom: true,
dblClickDragToZoom: true,
dblClickDragToZoom: false,
pinchToZoom: true,
zoomToRefPoint: true,
flickEnabled: true,
@ -1256,7 +1265,7 @@ function OpenSeadragon( options ){
},
zoomPerClick: 2,
zoomPerScroll: 1.2,
zoomPerDblClickDrag: 1.01,
zoomPerDblClickDrag: 1.2,
zoomPerSecond: 1.0,
blendTime: 0,
alwaysBlend: false,

View File

@ -214,7 +214,8 @@ $.Viewer = function( options ) {
fullPage: false,
onfullscreenchange: null,
lastClickTime: null,
draggingToZoom: false
draggingToZoom: false,
onClickActionTimeoutId: null,
};
this._sequenceIndex = 0;
@ -2904,12 +2905,23 @@ function onCanvasClick( event ) {
if ( !canvasClickEventArgs.preventDefaultAction && this.viewport && event.quick ) {
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
if ( gestureSettings.clickToZoom ) {
if(gestureSettings.clickToZoom === true && gestureSettings.dblClickDragToZoom === true){
var root = this;
var zoomImage = function() {
root.viewport.zoomBy(
event.shift ? 1.0 / root.zoomPerClick : root.zoomPerClick,
gestureSettings.zoomToRefPoint ? root.viewport.pointFromPixel( event.position, true ) : null
);
};
THIS[ this.hash ].onClickActionTimeoutId = setTimeout(zoomImage, 300);
}
else if (gestureSettings.clickToZoom === true){
this.viewport.zoomBy(
event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick,
gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
);
this.viewport.applyConstraints();
}
if( gestureSettings.dblClickDragToZoom){
@ -2955,6 +2967,10 @@ function onCanvasDblClick( event ) {
if ( !canvasDblClickEventArgs.preventDefaultAction && this.viewport ) {
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
if ( gestureSettings.dblClickToZoom ) {
this.viewport.zoomBy(
event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick,
gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
@ -3005,7 +3021,7 @@ function onCanvasDrag( event ) {
if (gestureSettings.dblClickDragToZoom && THIS[ this.hash ].draggingToZoom){
var factor = Math.pow( this.zoomPerDblClickDrag, event.delta.y);
var factor = Math.pow( this.zoomPerDblClickDrag, event.delta.y / 50);
this.viewport.zoomBy(factor);
}
else if (gestureSettings.dragToPan && !THIS[ this.hash ].draggingToZoom) {
@ -3208,7 +3224,9 @@ function onCanvasPress( event ) {
return;
}
if ((currClickTime - lastClickTime) < 2000) {
if ((currClickTime - lastClickTime) < 290) {
clearTimeout(THIS[ this.hash ].onClickActionTimeoutId);
THIS[ this.hash ].onClickActionTimeoutId = null;
THIS[ this.hash ].draggingToZoom = true;
}