@@ -370,7 +370,7 @@ define([
370
370
return false ;
371
371
}
372
372
373
- function zoomOut ( e , xStep , yStep ) {
373
+ function zoomOut ( e , xStep , yStep , fitIntoParentFlag = false ) {
374
374
var $image ,
375
375
widthResult ,
376
376
heightResult ,
@@ -381,8 +381,7 @@ define([
381
381
imageHeight ,
382
382
zoomWidthStep ,
383
383
zoomHeightStep ,
384
- ratio ,
385
- fitIntoParent ;
384
+ ratio ;
386
385
387
386
if ( allowZoomOut && ( ! transitionEnabled || ! transitionActive ) && ( isTouchEnabled ||
388
387
! $ ( zoomOutButtonSelector ) . hasClass ( zoomOutDisabled ) ) ) {
@@ -408,7 +407,7 @@ define([
408
407
zoomWidthStep = xStep || imageWidth - widthResult ;
409
408
}
410
409
411
- fitIntoParent = function ( ) {
410
+ let fitIntoParent = function ( ) {
412
411
if ( ratio > parentWidth / parentHeight ) {
413
412
widthResult = parentWidth ;
414
413
zoomWidthStep = imageWidth - widthResult ;
@@ -445,9 +444,11 @@ define([
445
444
} ;
446
445
checkFullscreenImagePosition ( $image , dimensions , zoomWidthStep , zoomHeightStep ) ;
447
446
} else {
448
- allowZoomOut = dragFlag = false ;
449
447
toggleStandartNavigation ( ) ;
450
- fitIntoParent ( ) ;
448
+ if ( fitIntoParentFlag ) {
449
+ allowZoomOut = dragFlag = false ;
450
+ fitIntoParent ( ) ;
451
+ }
451
452
}
452
453
} else if ( heightResult > parentHeight ) {
453
454
dimensions = {
@@ -462,9 +463,11 @@ define([
462
463
} ;
463
464
checkFullscreenImagePosition ( $image , dimensions , zoomWidthStep , zoomHeightStep ) ;
464
465
} else {
465
- allowZoomOut = dragFlag = false ;
466
466
toggleStandartNavigation ( ) ;
467
- fitIntoParent ( ) ;
467
+ if ( fitIntoParentFlag ) {
468
+ allowZoomOut = dragFlag = false ;
469
+ fitIntoParent ( ) ;
470
+ }
468
471
}
469
472
}
470
473
@@ -627,11 +630,11 @@ define([
627
630
) ;
628
631
629
632
if ( prevDiff > 0 ) {
630
- if ( curDiff > prevDiff && allowZoomIn ) {
631
- zoomIn ( ev , 1.5 * curDiff , 1.5 * curDiff ) ;
633
+ if ( curDiff - prevDiff > 0.2 && allowZoomIn ) {
634
+ zoomIn ( ev , curDiff , curDiff ) ;
632
635
}
633
- if ( curDiff < prevDiff && allowZoomOut ) {
634
- zoomOut ( ev , 1.5 * curDiff , 1.5 * curDiff ) ;
636
+ if ( curDiff - prevDiff < - 0.2 && allowZoomOut ) {
637
+ zoomOut ( ev , curDiff , curDiff ) ;
635
638
}
636
639
}
637
640
@@ -675,7 +678,12 @@ define([
675
678
if ( allowZoomIn ) {
676
679
zoomIn ( e , imgOriginalSize . rw - $image . width ( ) , imgOriginalSize . rh - $image . height ( ) ) ;
677
680
} else if ( allowZoomOut ) {
678
- zoomOut ( e , imgOriginalSize . rw * proportions , imgOriginalSize . rh - $imageContainer . height ( ) ) ;
681
+ zoomOut (
682
+ e ,
683
+ imgOriginalSize . rw * proportions ,
684
+ imgOriginalSize . rh - $imageContainer . height ( ) ,
685
+ true
686
+ ) ;
679
687
}
680
688
}
681
689
0 commit comments