@@ -585,6 +585,10 @@ - (void)showImageViewerByExpandingFromOriginalPositionFromViewController:(UIView
585
585
586
586
__weak JTSImageViewController *weakSelf = self;
587
587
588
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillBeginPresentation:withContainerView: )]) {
589
+ [weakSelf.animationDelegate imageViewerWillBeginPresentation: weakSelf withContainerView: weakSelf.view];
590
+ }
591
+
588
592
// Have to dispatch ahead two runloops,
589
593
// or else the image view changes above won't be
590
594
// committed prior to the animations below.
@@ -614,6 +618,10 @@ - (void)showImageViewerByExpandingFromOriginalPositionFromViewController:(UIView
614
618
options: UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
615
619
animations: ^{
616
620
621
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillAnimatePresentation:withContainerView:duration: )]) {
622
+ [weakSelf.animationDelegate imageViewerWillAnimatePresentation: weakSelf withContainerView: weakSelf.view duration: duration];
623
+ }
624
+
617
625
_flags.isTransitioningFromInitialModalToInteractiveState = YES ;
618
626
619
627
if ([UIApplication sharedApplication ].jts_usesViewControllerBasedStatusBarAppearance ) {
@@ -722,6 +730,10 @@ - (void)showImageViewerByScalingDownFromOffscreenPositionWithViewController:(UIV
722
730
723
731
__weak JTSImageViewController *weakSelf = self;
724
732
733
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillBeginPresentation:withContainerView: )]) {
734
+ [weakSelf.animationDelegate imageViewerWillBeginPresentation: weakSelf withContainerView: weakSelf.view];
735
+ }
736
+
725
737
// Have to dispatch to the next runloop,
726
738
// or else the image view changes above won't be
727
739
// committed prior to the animations below.
@@ -733,6 +745,10 @@ - (void)showImageViewerByScalingDownFromOffscreenPositionWithViewController:(UIV
733
745
options: UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
734
746
animations: ^{
735
747
748
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillAnimatePresentation:withContainerView:duration: )]) {
749
+ [weakSelf.animationDelegate imageViewerWillAnimatePresentation: weakSelf withContainerView: weakSelf.view duration: duration];
750
+ }
751
+
736
752
_flags.isTransitioningFromInitialModalToInteractiveState = YES ;
737
753
738
754
if ([UIApplication sharedApplication ].jts_usesViewControllerBasedStatusBarAppearance ) {
@@ -822,6 +838,10 @@ - (void)showAltTextFromViewController:(UIViewController *)viewController {
822
838
duration *= 4 ;
823
839
}
824
840
841
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillBeginPresentation:withContainerView: )]) {
842
+ [weakSelf.animationDelegate imageViewerWillBeginPresentation: weakSelf withContainerView: weakSelf.view];
843
+ }
844
+
825
845
// Have to dispatch to the next runloop,
826
846
// or else the image view changes above won't be
827
847
// committed prior to the animations below.
@@ -833,6 +853,10 @@ - (void)showAltTextFromViewController:(UIViewController *)viewController {
833
853
options: UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
834
854
animations: ^{
835
855
856
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillAnimatePresentation:withContainerView:duration: )]) {
857
+ [weakSelf.animationDelegate imageViewerWillAnimatePresentation: weakSelf withContainerView: weakSelf.view duration: duration];
858
+ }
859
+
836
860
_flags.isTransitioningFromInitialModalToInteractiveState = YES ;
837
861
838
862
if ([UIApplication sharedApplication ].jts_usesViewControllerBasedStatusBarAppearance ) {
@@ -944,6 +968,10 @@ - (void)dismissByCollapsingImageBackToOriginalPosition {
944
968
945
969
__weak JTSImageViewController *weakSelf = self;
946
970
971
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillBeginDismissal:withContainerView: )]) {
972
+ [weakSelf.animationDelegate imageViewerWillBeginDismissal: weakSelf withContainerView: weakSelf.view];
973
+ }
974
+
947
975
// Have to dispatch after or else the image view changes above won't be
948
976
// committed prior to the animations below. A single dispatch_async(dispatch_get_main_queue()
949
977
// wouldn't work under certain scrolling conditions, so it has to be an ugly
@@ -966,6 +994,10 @@ - (void)dismissByCollapsingImageBackToOriginalPosition {
966
994
967
995
[UIView animateWithDuration: duration delay: 0 options: UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations: ^{
968
996
997
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillAnimateDismissal:withContainerView:duration: )]) {
998
+ [weakSelf.animationDelegate imageViewerWillAnimateDismissal: weakSelf withContainerView: weakSelf.view duration: duration];
999
+ }
1000
+
969
1001
weakSelf.snapshotView .transform = weakSelf.currentSnapshotRotationTransform ;
970
1002
[weakSelf removeMotionEffectsFromSnapshotView ];
971
1003
weakSelf.blackBackdrop .alpha = 0 ;
@@ -1037,7 +1069,16 @@ - (void)dismissByCleaningUpAfterImageWasFlickedOffscreen {
1037
1069
duration *= 4 ;
1038
1070
}
1039
1071
1072
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillBeginDismissal:withContainerView: )]) {
1073
+ [weakSelf.animationDelegate imageViewerWillBeginDismissal: weakSelf withContainerView: weakSelf.view];
1074
+ }
1075
+
1040
1076
[UIView animateWithDuration: duration delay: 0 options: UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations: ^{
1077
+
1078
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillAnimateDismissal:withContainerView:duration: )]) {
1079
+ [weakSelf.animationDelegate imageViewerWillAnimateDismissal: weakSelf withContainerView: weakSelf.view duration: duration];
1080
+ }
1081
+
1041
1082
weakSelf.snapshotView .transform = weakSelf.currentSnapshotRotationTransform ;
1042
1083
[weakSelf removeMotionEffectsFromSnapshotView ];
1043
1084
weakSelf.blackBackdrop .alpha = 0 ;
@@ -1071,7 +1112,16 @@ - (void)dismissByExpandingImageToOffscreenPosition {
1071
1112
duration *= 4 ;
1072
1113
}
1073
1114
1115
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillBeginDismissal:withContainerView: )]) {
1116
+ [weakSelf.animationDelegate imageViewerWillBeginDismissal: weakSelf withContainerView: weakSelf.view];
1117
+ }
1118
+
1074
1119
[UIView animateWithDuration: duration delay: 0 options: UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations: ^{
1120
+
1121
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillAnimateDismissal:withContainerView:duration: )]) {
1122
+ [weakSelf.animationDelegate imageViewerWillAnimateDismissal: weakSelf withContainerView: weakSelf.view duration: duration];
1123
+ }
1124
+
1075
1125
weakSelf.snapshotView .transform = weakSelf.currentSnapshotRotationTransform ;
1076
1126
[weakSelf removeMotionEffectsFromSnapshotView ];
1077
1127
weakSelf.blackBackdrop .alpha = 0 ;
@@ -1116,7 +1166,16 @@ - (void)dismissByExpandingAltTextToOffscreenPosition {
1116
1166
self.textView .delegate = nil ;
1117
1167
self.textView = nil ;
1118
1168
1169
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillBeginDismissal:withContainerView: )]) {
1170
+ [weakSelf.animationDelegate imageViewerWillBeginDismissal: weakSelf withContainerView: weakSelf.view];
1171
+ }
1172
+
1119
1173
[UIView animateWithDuration: duration delay: 0 options: UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations: ^{
1174
+
1175
+ if ([weakSelf.animationDelegate respondsToSelector: @selector (imageViewerWillAnimateDismissal:withContainerView:duration: )]) {
1176
+ [weakSelf.animationDelegate imageViewerWillAnimateDismissal: weakSelf withContainerView: weakSelf.view duration: duration];
1177
+ }
1178
+
1120
1179
weakSelf.snapshotView .transform = weakSelf.currentSnapshotRotationTransform ;
1121
1180
[weakSelf removeMotionEffectsFromSnapshotView ];
1122
1181
weakSelf.blackBackdrop .alpha = 0 ;
@@ -1496,9 +1555,13 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
1496
1555
#pragma mark - Update Dimming View for Zoom Scale
1497
1556
1498
1557
- (void )updateDimmingViewForCurrentZoomScale : (BOOL )animated {
1499
- CGFloat targetAlpha = (self.scrollView .zoomScale > 1 ) ? 1 .0f : self.alphaForBackgroundDimmingOverlay ;
1558
+ CGFloat zoomScale = self.scrollView .zoomScale ;
1559
+ CGFloat targetAlpha = (zoomScale > 1 ) ? 1 .0f : self.alphaForBackgroundDimmingOverlay ;
1500
1560
CGFloat duration = (animated) ? 0.35 : 0 ;
1501
1561
[UIView animateWithDuration: duration delay: 0 options: UIViewAnimationOptionCurveLinear | UIViewAnimationOptionBeginFromCurrentState animations: ^{
1562
+ if ([self .animationDelegate respondsToSelector: @selector (imageViewer:willAdjustInterfaceForZoomScale:withContainerView:duration: )]) {
1563
+ [self .animationDelegate imageViewer: self willAdjustInterfaceForZoomScale: zoomScale withContainerView: self .view duration: duration];
1564
+ }
1502
1565
self.blackBackdrop .alpha = targetAlpha;
1503
1566
} completion: nil ];
1504
1567
}
0 commit comments