@@ -34,14 +34,16 @@ - (instancetype)initWithOperation:(UINavigationControllerOperation)operation
3434 self = [super init ];
3535 if (self) {
3636 _operation = operation;
37+ _duration = DURATION;
38+ _maxDelay = MAX_DELAY;
3739 _transitionType = AMWaveTransitionTypeNervous;
3840 }
3941 return self;
4042}
4143
4244- (NSTimeInterval )transitionDuration : (id <UIViewControllerContextTransitioning>)transitionContext
4345{
44- return DURATION + MAX_DELAY ;
46+ return self. duration + self. maxDelay ;
4547}
4648
4749- (void )animateTransition : (id <UIViewControllerContextTransitioning>)transitionContext
@@ -77,22 +79,20 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
7779 toVC.view .transform = CGAffineTransformMakeTranslation (SCREEN_WIDTH, 0 );
7880
7981 // First step is required to trigger the load of the visible cells.
80- [UIView animateWithDuration: 0 delay: 0 options: UIViewAnimationOptionCurveEaseIn animations: ^{
81- // toVC.view.transform = CGAffineTransformMakeTranslation(SCREEN_WIDTH, 0);
82- } completion: ^(BOOL finished) {
82+ [UIView animateWithDuration: 0 delay: 0 options: UIViewAnimationOptionCurveEaseIn animations: nil completion: ^(BOOL finished) {
8383
8484 // Plain animation that moves the destination controller in place. Once it's done it will notify the transition context
8585 if (self.operation == UINavigationControllerOperationPush) {
8686 [toVC.view setTransform: CGAffineTransformMakeTranslation (1 , 0 )];
87- [UIView animateWithDuration: DURATION + MAX_DELAY delay: 0 options: UIViewAnimationOptionCurveEaseIn animations: ^{
87+ [UIView animateWithDuration: self .duration + self .maxDelay delay: 0 options: UIViewAnimationOptionCurveEaseIn animations: ^{
8888 [toVC.view setTransform: CGAffineTransformIdentity];
8989 } completion: ^(BOOL finished) {
9090 [transitionContext completeTransition: YES ];
9191 }];
9292 } else {
9393 [fromVC.view setTransform: CGAffineTransformMakeTranslation (1 , 0 )];
9494 [toVC.view setTransform: CGAffineTransformIdentity];
95- [UIView animateWithDuration: DURATION + MAX_DELAY delay: 0 options: UIViewAnimationOptionCurveEaseIn animations: ^{
95+ [UIView animateWithDuration: self .duration + self .maxDelay delay: 0 options: UIViewAnimationOptionCurveEaseIn animations: ^{
9696 [fromVC.view setTransform: CGAffineTransformMakeTranslation (SCREEN_WIDTH, 0 )];
9797 } completion: ^(BOOL finished) {
9898 [transitionContext completeTransition: YES ];
@@ -103,7 +103,7 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
103103 // Animates the cells of the starting view controller
104104 if ([fromVC respondsToSelector: @selector (visibleCells )]) {
105105 [[fromVC visibleCells ] enumerateObjectsWithOptions: NSEnumerationReverse usingBlock: ^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) {
106- NSTimeInterval delay = ((float )idx / (float )[[fromVC visibleCells ] count ]) * MAX_DELAY ;
106+ NSTimeInterval delay = ((float )idx / (float )[[fromVC visibleCells ] count ]) * self. maxDelay ;
107107 void (^animation)() = ^{
108108 [obj setTransform: CGAffineTransformMakeTranslation (-delta, 0 )];
109109 [obj setAlpha: 0 ];
@@ -112,25 +112,25 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
112112 [obj setTransform: CGAffineTransformIdentity];
113113 };
114114 if (self.transitionType == AMWaveTransitionTypeSubtle) {
115- [UIView animateWithDuration: DURATION delay: delay options: UIViewAnimationOptionCurveEaseIn animations: animation completion: completion];
115+ [UIView animateWithDuration: self .duration delay: delay options: UIViewAnimationOptionCurveEaseIn animations: animation completion: completion];
116116 } else {
117- [UIView animateWithDuration: DURATION delay: delay usingSpringWithDamping: 0.75 initialSpringVelocity: 1 options: UIViewAnimationOptionCurveEaseIn animations: animation completion: completion];
117+ [UIView animateWithDuration: self .duration delay: delay usingSpringWithDamping: 0.75 initialSpringVelocity: 1 options: UIViewAnimationOptionCurveEaseIn animations: animation completion: completion];
118118 }
119119 }];
120120 }
121121
122122 if ([toVC respondsToSelector: @selector (visibleCells )]) {
123123 [[toVC visibleCells ] enumerateObjectsWithOptions: NSEnumerationReverse usingBlock: ^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) {
124- NSTimeInterval delay = ((float )idx / (float )[[fromVC visibleCells ] count ]) * MAX_DELAY ;
124+ NSTimeInterval delay = ((float )idx / (float )[[fromVC visibleCells ] count ]) * self. maxDelay ;
125125 [obj setTransform: CGAffineTransformMakeTranslation (delta, 0 )];
126126 void (^animation)() = ^{
127127 [obj setTransform: CGAffineTransformIdentity];
128128 [obj setAlpha: 1 ];
129129 };
130130 if (self.transitionType == AMWaveTransitionTypeSubtle) {
131- [UIView animateWithDuration: DURATION delay: delay options: UIViewAnimationOptionCurveEaseIn animations: animation completion: nil ];
131+ [UIView animateWithDuration: self .duration delay: delay options: UIViewAnimationOptionCurveEaseIn animations: animation completion: nil ];
132132 } else {
133- [UIView animateWithDuration: DURATION delay: delay usingSpringWithDamping: 0.75 initialSpringVelocity: 1 options: UIViewAnimationOptionCurveEaseIn animations: animation completion: nil ];
133+ [UIView animateWithDuration: self .duration delay: delay usingSpringWithDamping: 0.75 initialSpringVelocity: 1 options: UIViewAnimationOptionCurveEaseIn animations: animation completion: nil ];
134134 }
135135 }];
136136 }
0 commit comments