From 6232df3bfa1ceee5d1f7420037beb1c01b49f960 Mon Sep 17 00:00:00 2001 From: David Sinclair Date: Mon, 26 Oct 2015 20:28:38 -0700 Subject: [PATCH] iOS: fixed #769 (Safari swipe to dismiss) Now uses a linear animation curve when tracking the gesture, so it follows the finger, and an ease in/out curve and the same speed as other animations when not. --- clients/ios/Classes/NBModalPushPopTransition.m | 8 +++++--- clients/ios/Classes/NewsBlurAppDelegate.m | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clients/ios/Classes/NBModalPushPopTransition.m b/clients/ios/Classes/NBModalPushPopTransition.m index 6ac700985..7504f68d3 100644 --- a/clients/ios/Classes/NBModalPushPopTransition.m +++ b/clients/ios/Classes/NBModalPushPopTransition.m @@ -22,7 +22,7 @@ } - (CGFloat)transitionDuration:(id )transitionContext { - return 0.75; + return 0.35; } - (void)animateTransition:(id)transitionContext { @@ -56,7 +56,7 @@ shadowView.transform = self.dismissing ? CGAffineTransformMakeScale(0.01, 1.0) : CGAffineTransformIdentity; shadowView.alpha = self.dismissing ? 1.0 : 0.0; - [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0.0 usingSpringWithDamping:0.9 initialSpringVelocity:1.0 options:self.animationOpts animations:^{ + [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0.0 options:[self animationOpts] animations:^{ topView.transform = self.dismissing ? CGAffineTransformMakeTranslation(offset, 0.0) : CGAffineTransformIdentity; shadowView.transform = self.dismissing ? CGAffineTransformIdentity : CGAffineTransformMakeScale(0.01, 1.0); shadowView.alpha = self.dismissing ? 0.0 : 1.0; @@ -68,7 +68,9 @@ } - (UIViewAnimationOptions)animationOpts { - return UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionLayoutSubviews; + UIViewAnimationOptions opts = self.percentageDriven ? UIViewAnimationOptionCurveLinear : UIViewAnimationOptionCurveEaseInOut; + + return opts | UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionLayoutSubviews; } @end diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index 6178b49f2..3969c835c 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -1371,7 +1371,7 @@ - (void)handleGesture:(UIScreenEdgePanGestureRecognizer *)recognizer { self.safariAnimator.percentageDriven = YES; - CGFloat percentComplete = [recognizer locationInView:self.view].x / self.view.bounds.size.width / 2.0; + CGFloat percentComplete = [recognizer locationInView:self.view].x / self.view.bounds.size.width; switch (recognizer.state) { case UIGestureRecognizerStateBegan: