Skip to content

Commit

Permalink
Merge pull request #8 from makingspace/NaN-check
Browse files Browse the repository at this point in the history
NaN check
  • Loading branch information
scalessec committed Nov 1, 2016
2 parents 50d5e44 + f39cd12 commit e114f39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ZOZolaZoomTransition.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ZOZolaZoomTransition"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "Zoom transition that animates the entire view heirarchy. It is used extensively in the Zola iOS application."
s.homepage = "https://github.com/NewAmsterdamLabs/ZOZolaZoomTransition"
s.license = 'MIT'
Expand Down
32 changes: 18 additions & 14 deletions ZOZolaZoomTransition/ZOZolaZoomTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
NSAssert([_delegate respondsToSelector:@selector(zolaZoomTransition:frameForSupplementaryView:relativeToView:)], @"supplementaryViewsForZolaZoomTransition: requires zolaZoomTransition:frameForSupplementaryView:relativeToView: to be implemented by the delegate. Implement zolaZoomTransition:frameForSupplementaryView:relativeToView: and try again.");
supplementaryViews = [_delegate supplementaryViewsForZolaZoomTransition:self];
}

// All supplementary snapshots are added to a container, and then the same transform
// that we're going to apply to the "from" controller snapshot will be applied to the
// supplementary container
Expand Down Expand Up @@ -222,18 +222,20 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
animations:^{
// Transform and move the "from" snapshot
fromControllerSnapshot.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
fromControllerSnapshot.frame = CGRectMake(endPoint.x, endPoint.y, fromControllerSnapshot.frame.size.width, fromControllerSnapshot.frame.size.height);

// Transform and move the supplementary container with the "from" snapshot
supplementaryContainer.transform = fromControllerSnapshot.transform;
supplementaryContainer.frame = fromControllerSnapshot.frame;

// Fade
fadeView.alpha = 1.0;
supplementaryContainer.alpha = 0.0;

// Move our target snapshot into position
targetSnapshot.frame = finishFrame;
if (!isnan(endPoint.x) && !isnan(endPoint.y)) {
fromControllerSnapshot.frame = CGRectMake(endPoint.x, endPoint.y, fromControllerSnapshot.frame.size.width, fromControllerSnapshot.frame.size.height);

// Transform and move the supplementary container with the "from" snapshot
supplementaryContainer.transform = fromControllerSnapshot.transform;
supplementaryContainer.frame = fromControllerSnapshot.frame;

// Fade
fadeView.alpha = 1.0;
supplementaryContainer.alpha = 0.0;

// Move our target snapshot into position
targetSnapshot.frame = finishFrame;
}
} completion:^(BOOL finished) {
// Add "to" controller view
[containerView addSubview:toControllerView];
Expand Down Expand Up @@ -294,7 +296,9 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC

// Apply the transformation and set the origin before the animation begins
toControllerSnapshot.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
toControllerSnapshot.frame = CGRectMake(startPoint.x, startPoint.y, toControllerSnapshot.frame.size.width, toControllerSnapshot.frame.size.height);
if (!isnan(startPoint.x) && !isnan(startPoint.y)) {
toControllerSnapshot.frame = CGRectMake(startPoint.x, startPoint.y, toControllerSnapshot.frame.size.width, toControllerSnapshot.frame.size.height);
}

// Apply the same transform and starting position to the supplementary container
supplementaryContainer.transform = toControllerSnapshot.transform;
Expand Down

0 comments on commit e114f39

Please sign in to comment.