Advertisement
redribben

panning exploration

Feb 16th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)recognizer {
  2.     CGFloat translationX  = [recognizer translationInView:self.slidingViewController.view].x;
  3.     CGFloat velocityX     = [recognizer velocityInView:self.slidingViewController.view].x;
  4. NSLog(@"PANNING 0 GOING ON!!!");
  5. //    if (recognizer) {
  6. //        [[UIApplication sharedApplication] setStatusBarHidden:YES];
  7. //    }
  8.    
  9.    
  10.     switch (recognizer.state) {
  11.         case UIGestureRecognizerStateBegan: {
  12.             BOOL isMovingRight = velocityX > 0;
  13.  
  14.             if (self.slidingViewController.currentTopViewPosition == ECSlidingViewControllerTopViewPositionCentered && isMovingRight) {
  15.                 [self.slidingViewController anchorTopViewToRightAnimated:YES];
  16.                 NSLog(@"PANNING 1 GOING ON!!!");
  17.             } else if (self.slidingViewController.currentTopViewPosition == ECSlidingViewControllerTopViewPositionCentered && !isMovingRight) {
  18.                 [self.slidingViewController anchorTopViewToLeftAnimated:YES];
  19.                 NSLog(@"PANNING 2 GOING ON!!!");
  20.             } else if (self.slidingViewController.currentTopViewPosition == ECSlidingViewControllerTopViewPositionAnchoredLeft) {
  21.                 [self.slidingViewController resetTopViewAnimated:YES];
  22.                 NSLog(@"PANNING 3 GOING ON!!!");
  23.             } else if (self.slidingViewController.currentTopViewPosition == ECSlidingViewControllerTopViewPositionAnchoredRight) {
  24.                 [self.slidingViewController resetTopViewAnimated:YES];
  25.                 NSLog(@"PANNING 4 GOING ON!!!");
  26.             }
  27.            
  28.             break;
  29.         }
  30.         case UIGestureRecognizerStateChanged: {
  31.             if (!self.positiveLeftToRight) translationX = translationX * -1.0;
  32.             CGFloat percentComplete = (translationX / self.fullWidth);
  33.             if (percentComplete < 0) percentComplete = 0;
  34.             [self updateInteractiveTransition:percentComplete];
  35.             NSLog(@"PANNING 5 GOING ON!!!");
  36.             break;
  37.         }
  38.         case UIGestureRecognizerStateEnded:
  39.             NSLog(@"PANNING 6 GOING ON!!!");
  40.         case UIGestureRecognizerStateCancelled: {
  41.             BOOL isPanningRight = velocityX > 0;
  42.            
  43.             if (self.coordinatorInteractionEnded) self.coordinatorInteractionEnded((id<UIViewControllerTransitionCoordinatorContext>)self.slidingViewController);
  44.            
  45.             if (isPanningRight && self.positiveLeftToRight) {
  46.                 [self finishInteractiveTransition];
  47.             } else if (isPanningRight && !self.positiveLeftToRight) {
  48.                 [self cancelInteractiveTransition];
  49.             } else if (!isPanningRight && self.positiveLeftToRight) {
  50.                 [self cancelInteractiveTransition];
  51.             } else if (!isPanningRight && !self.positiveLeftToRight) {
  52.                 [self finishInteractiveTransition];
  53.             }
  54.             NSLog(@"PANNING 7 GOING ON!!!");
  55.             break;
  56.         }
  57.         default:
  58.             break;
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement