From 2f2285711df249b802a2f12be93a14dc0e3c652c Mon Sep 17 00:00:00 2001 From: Hamza Tatheer Date: Sun, 23 Oct 2022 01:30:16 +0500 Subject: [PATCH] Update viewer.js --- src/viewer.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index 639bbb73..a9a139ad 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -3039,6 +3039,7 @@ function onCanvasDrag( event ) { } function onCanvasDragEnd( event ) { + var gestureSettings; var canvasDragEndEventArgs = { tracker: event.eventSource, pointerType: event.pointerType, @@ -3069,9 +3070,11 @@ function onCanvasDragEnd( event ) { */ this.raiseEvent('canvas-drag-end', canvasDragEndEventArgs); + gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); + if (!canvasDragEndEventArgs.preventDefaultAction && this.viewport) { - var gestureSettings = this.gestureSettingsByDeviceType(event.pointerType); - if (gestureSettings.flickEnabled && + if ( !THIS[ this.hash ].draggingToZoom && + gestureSettings.flickEnabled && event.speed >= gestureSettings.flickMinSpeed) { var amplitudeX = 0; if (this.panHorizontal) { @@ -3091,6 +3094,13 @@ function onCanvasDragEnd( event ) { } this.viewport.applyConstraints(); } + + + if( gestureSettings.dblClickToZoom && THIS[ this.hash ].draggingToZoom === true ){ + THIS[ this.hash ].draggingToZoom = false; + } + + } function onCanvasEnter( event ) { @@ -3205,8 +3215,6 @@ function onCanvasPress( event ) { } function onCanvasRelease( event ) { - var gestureSettings; - /** * Raised when the primary mouse button is released or touch ends on the {@link OpenSeadragon.Viewer#canvas} element. * @@ -3230,13 +3238,6 @@ function onCanvasRelease( event ) { insideElementReleased: event.insideElementReleased, originalEvent: event.originalEvent }); - - gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); - - if( gestureSettings.dblClickToZoom ){ - THIS[ this.hash ].draggingToZoom = false; - } - } function onCanvasNonPrimaryPress( event ) {