diff --git a/CHANGELOG.md b/CHANGELOG.md index ae2c2fdc..b21ad6b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changes for users of the library currently on `develop`: - Fixed some tests, added tests for NYTPhotoViewerSinglePhotoDataSource - Fixed a strict warning and a subscripting bug in NYTPhotoViewerArrayDataSource.m - Added support for interstitial views +- Fix NYTPhotoTransitionAnimator translation animation, when the target photo is gif and FLAnimatedImageView is used. ## [2.0.0](https://github.com/NYTimes/NYTPhotoViewer/releases/tag/2.0.0) diff --git a/NYTPhotoViewer/NYTPhotoTransitionAnimator.m b/NYTPhotoViewer/NYTPhotoTransitionAnimator.m index aa80441d..4343ecb2 100644 --- a/NYTPhotoViewer/NYTPhotoTransitionAnimator.m +++ b/NYTPhotoViewer/NYTPhotoTransitionAnimator.m @@ -8,6 +8,11 @@ #import "NYTPhotoTransitionAnimator.h" +#ifdef ANIMATED_GIF_SUPPORT +#import +#endif + + static const CGFloat NYTPhotoTransitionAnimatorDurationWithZooming = 0.5; static const CGFloat NYTPhotoTransitionAnimatorDurationWithoutZooming = 0.3; static const CGFloat NYTPhotoTransitionAnimatorBackgroundFadeDurationRatio = 4.0 / 9.0; @@ -245,6 +250,11 @@ + (UIView *)newAnimationViewFromView:(UIView *)view { animationView.contentMode = view.contentMode; animationView.transform = view.transform; } +#ifdef ANIMATED_GIF_SUPPORT + else if ([view isKindOfClass:[FLAnimatedImageView class]]) { + animationView = [self snapshotViewForFLAnimatedView:(FLAnimatedImageView *)view]; + } +#endif else { animationView = [view snapshotViewAfterScreenUpdates:YES]; } @@ -252,6 +262,23 @@ + (UIView *)newAnimationViewFromView:(UIView *)view { return animationView; } +#ifdef ANIMATED_GIF_SUPPORT ++ (UIView *)snapshotViewForFLAnimatedView:(FLAnimatedImageView *)imageView { + UIView *tarImageView = nil; + if (imageView.image) { + tarImageView = [[UIImageView alloc] initWithImage:imageView.image]; + } else if (imageView.animatedImage) { + tarImageView = [[UIImageView alloc] initWithImage:imageView.currentFrame]; + } else { + tarImageView = [imageView snapshotViewAfterScreenUpdates:YES]; + return tarImageView; + } + + tarImageView.bounds = imageView.bounds; + return tarImageView; +} +#endif + #pragma mark - UIViewControllerAnimatedTransitioning - (NSTimeInterval)transitionDuration:(id )transitionContext {