Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix NYTPhotoTransitionAnimator translation animation, when the target photo is gif and FLAnimatedImageView is used #277

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
27 changes: 27 additions & 0 deletions NYTPhotoViewer/NYTPhotoTransitionAnimator.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

#import "NYTPhotoTransitionAnimator.h"

#ifdef ANIMATED_GIF_SUPPORT
#import <FLAnimatedImage/FLAnimatedImage.h>
#endif


static const CGFloat NYTPhotoTransitionAnimatorDurationWithZooming = 0.5;
static const CGFloat NYTPhotoTransitionAnimatorDurationWithoutZooming = 0.3;
static const CGFloat NYTPhotoTransitionAnimatorBackgroundFadeDurationRatio = 4.0 / 9.0;
Expand Down Expand Up @@ -245,13 +250,35 @@ + (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];
}

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 <UIViewControllerContextTransitioning>)transitionContext {
Expand Down