@@ -30,7 +30,7 @@ define([
30
30
dragFlag ,
31
31
endX ,
32
32
transitionActive = false ,
33
- tapedTwice = false ,
33
+ tapFlag = 0 ,
34
34
allowZoomOut = false ,
35
35
allowZoomIn = true ;
36
36
@@ -504,6 +504,7 @@ define([
504
504
$imageContainer = $ ( '[data-gallery-role="stage-shaft"] [data-active="true"]' ) ,
505
505
gallery = $gallery . data ( 'fotorama' ) ,
506
506
pinchDimention ;
507
+
507
508
swipeSlide = _ . throttle ( function ( direction ) {
508
509
$ ( gallerySelector ) . data ( 'fotorama' ) . show ( direction ) ;
509
510
} , 500 , {
@@ -579,6 +580,10 @@ define([
579
580
var imgOriginalSize = getImageSize ( $image [ 0 ] . src ) ,
580
581
proportions ;
581
582
583
+ if ( imgOriginalSize . rh < $image . parent ( ) . height ( ) && imgOriginalSize . rw < $image . parent ( ) . width ( ) ) {
584
+ return ;
585
+ }
586
+
582
587
proportions = imgOriginalSize . rw / imgOriginalSize . rh ;
583
588
584
589
if ( allowZoomIn ) {
@@ -592,8 +597,30 @@ define([
592
597
}
593
598
}
594
599
595
- $image . unbind ( 'dblclick' ) ;
596
- $image . dblclick ( dblClickHandler ) ;
600
+ function detectDoubleTap ( e ) {
601
+ var now = new Date ( ) . getTime ( ) ,
602
+ timesince = now - tapFlag ;
603
+
604
+ if ( timesince < 400 && timesince > 0 ) {
605
+ transitionActive = false ;
606
+ tapFlag = 0 ;
607
+ dblClickHandler ( e ) ;
608
+ } else {
609
+ tapFlag = new Date ( ) . getTime ( ) ;
610
+ }
611
+ }
612
+
613
+ if ( isTouchEnabled ) {
614
+ $image . off ( 'tap' ) ;
615
+ $image . on ( 'tap' , function ( e ) {
616
+ if ( e . originalEvent . originalEvent . touches . length === 0 ) {
617
+ detectDoubleTap ( e ) ;
618
+ }
619
+ } ) ;
620
+ } else {
621
+ $image . unbind ( 'dblclick' ) ;
622
+ $image . dblclick ( dblClickHandler ) ;
623
+ }
597
624
598
625
if ( gallery . fullScreen ) {
599
626
toggleZoomButtons ( $image , isTouchEnabled , checkForVideo ( fotorama . activeFrame . $stageFrame ) ) ;
@@ -611,6 +638,7 @@ define([
611
638
e . preventDefault ( ) ;
612
639
pinchDimention = getDimention ( e . originalEvent ) ;
613
640
isDragActive = false ;
641
+
614
642
if ( $image . hasClass ( imageDraggableClass ) ) {
615
643
$image . removeClass ( imageDraggableClass ) ;
616
644
}
@@ -642,6 +670,7 @@ define([
642
670
if ( e && e . originalEvent . touches && e . originalEvent . touches . length >= 2 ) {
643
671
e . preventDefault ( ) ;
644
672
var currentDimention = getDimention ( e . originalEvent ) ;
673
+
645
674
if ( $image . hasClass ( imageDraggableClass ) ) {
646
675
$image . removeClass ( imageDraggableClass ) ;
647
676
}
@@ -698,7 +727,7 @@ define([
698
727
imagePosX = $ ( fullscreenImageSelector , $gallery ) . offset ( ) . left ;
699
728
imagePosY = $ ( fullscreenImageSelector , $gallery ) . offset ( ) . top ;
700
729
} ;
701
-
730
+
702
731
if ( ( $focus . attr ( 'data-gallery-role' ) || ! $focus . length ) && allowZoomOut ) {
703
732
if ( isFullScreen ) {
704
733
imagePosX = $ ( fullscreenImageSelector , $ ( gallerySelector ) ) . offset ( ) . left ;
@@ -738,7 +767,7 @@ define([
738
767
}
739
768
}
740
769
}
741
-
770
+
742
771
if ( e . keyCode === 27 && isFullScreen && allowZoomOut ) {
743
772
$ ( gallerySelector ) . data ( 'fotorama' ) . cancelFullScreen ( ) ;
744
773
}
@@ -752,7 +781,7 @@ define([
752
781
$ ( document ) . on ( isTouchEnabled ? 'touchend' : 'mouseup pointerup MSPointerUp' , function ( e ) {
753
782
if ( gallery . fullScreen ) {
754
783
755
- if ( $image . offset ( ) && ( $image . width ( ) > $imageContainer . width ( ) ) ) {
784
+ if ( $image . offset ( ) && $image . width ( ) > $imageContainer . width ( ) ) {
756
785
endX = $image . offset ( ) . left ;
757
786
}
758
787
@@ -761,29 +790,22 @@ define([
761
790
}
762
791
} ) ;
763
792
764
- isTouchEnabled && $image . off ( 'touchend' ) ;
765
- isTouchEnabled && $image . on ( 'touchend' , function ( e ) {
766
- if ( e . originalEvent . touches . length === 0 ) {
767
- if ( ! tapedTwice ) {
768
- tapedTwice = true ;
769
- setTimeout ( function ( ) {
770
- tapedTwice = false ;
771
- } , 300 ) ;
772
-
773
- return ;
774
- }
775
- toggleZoomable ( $image , allowZoomOut ) ;
776
- dblClickHandler ( e ) ;
777
- }
778
- } ) ;
779
-
780
-
781
793
$ ( window ) . resize ( function ( ) {
794
+ var imageSize = getImageSize ( $ ( fullscreenImageSelector ) [ 0 ] . src ) ,
795
+ isImageSmall =
796
+ $ ( fullscreenImageSelector ) . parent ( ) . width ( ) >= imageSize . rw &&
797
+ $ ( fullscreenImageSelector ) . parent ( ) . height ( ) >= imageSize . rh ;
798
+
782
799
toggleZoomButtons ( $image , isTouchEnabled , checkForVideo ( fotorama . activeFrame . $stageFrame ) ) ;
783
800
calculateMinSize ( $image ) ;
784
- if ( $image . hasClass ( imageZoommable ) && ! allowZoomOut ) {
801
+
802
+ if ( $image . hasClass ( imageZoommable ) && ! allowZoomOut || isImageSmall ) {
785
803
resetVars ( $image ) ;
786
804
}
805
+
806
+ if ( ! isImageSmall ) {
807
+ toggleStandartNavigation ( ) ;
808
+ }
787
809
} ) ;
788
810
}
789
811
@@ -814,7 +836,7 @@ define([
814
836
isClick = initPos [ 0 ] === pos [ 0 ] && initPos [ 1 ] === pos [ 1 ] ,
815
837
isImg = $ ( e . target ) . parent ( ) . data ( 'active' ) ;
816
838
817
- if ( isArrow || ( isImg && ! isClick ) ) {
839
+ if ( isArrow || isImg && ! isClick ) {
818
840
hideMagnifier ( ) ;
819
841
}
820
842
}
@@ -854,8 +876,10 @@ define([
854
876
855
877
$ ( element ) . on ( 'fotorama:load fotorama:showend fotorama:fullscreenexit fotorama:ready' , function ( e , fotorama ) {
856
878
var $activeStageFrame = $ ( gallerySelector ) . data ( 'fotorama' ) . activeFrame . $stageFrame ;
879
+
857
880
if ( ! $activeStageFrame . find ( magnifierZoomSelector ) . length ) {
858
881
hideMagnifier ( ) ;
882
+
859
883
if ( config . magnifierOpts ) {
860
884
config . magnifierOpts . large = $ ( gallerySelector ) . data ( 'fotorama' ) . activeFrame . img ;
861
885
config . magnifierOpts . full = fotorama . data [ fotorama . activeIndex ] . original ;
@@ -920,27 +944,33 @@ define([
920
944
} )
921
945
. on ( 'fotorama:fullscreenenter fotorama:showend' , function ( e , fotorama ) {
922
946
hideMagnifier ( ) ;
923
- ! tapedTwice && resetVars ( $ ( fullscreenImageSelector ) ) ;
947
+
948
+ if ( ! $ ( fullscreenImageSelector ) . is ( $prevImage ) ) {
949
+ resetVars ( $ ( fullscreenImageSelector ) ) ;
950
+ }
924
951
magnifierFullscreen ( fotorama ) ;
925
952
mousewheel ( e , fotorama , element ) ;
926
953
927
954
if ( $prevImage ) {
928
955
calculateMinSize ( $prevImage ) ;
929
- resetVars ( $prevImage ) ;
956
+
957
+ if ( ! $ ( fullscreenImageSelector ) . is ( $prevImage ) ) {
958
+ resetVars ( $prevImage ) ;
959
+ }
930
960
}
931
961
932
962
toggleStandartNavigation ( ) ;
933
963
} )
934
964
. on ( 'fotorama:load' , function ( e , fotorama ) {
935
965
if ( $ ( gallerySelector ) . data ( 'fotorama' ) . fullScreen ) {
936
- toggleZoomButtons ( $ ( fullscreenImageSelector ) , isTouchEnabled , checkForVideo ( fotorama . activeFrame . $stageFrame ) ) ;
966
+ toggleZoomButtons ( $ ( fullscreenImageSelector ) , isTouchEnabled ,
967
+ checkForVideo ( fotorama . activeFrame . $stageFrame ) ) ;
937
968
}
938
969
magnifierFullscreen ( fotorama ) ;
939
970
} )
940
971
. on ( 'fotorama:show' , function ( e , fotorama ) {
941
- $prevImage = $ ( fullscreenImageSelector ) ;
972
+ $prevImage = _ . clone ( $ ( fullscreenImageSelector ) ) ;
942
973
hideMagnifier ( ) ;
943
- ! tapedTwice && resetVars ( $ ( fullscreenImageSelector ) ) ;
944
974
} )
945
975
. on ( 'fotorama:fullscreenexit' , function ( e , fotorama ) {
946
976
resetVars ( $ ( fullscreenImageSelector ) ) ;
0 commit comments