Skip to content

Commit

Permalink
Refactor rotation methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
André Schneider committed Jun 30, 2014
1 parent f1a84a8 commit b361122
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Popping/FoldView.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @interface FoldView()
- (void)addTopView;
- (void)addBottomView;
- (void)addGestureRecognizers;
- (void)rotateToOrigin;
- (void)rotateToOriginWithVelocity:(CGFloat)velocity;
- (void)poke;
- (void)handlePan:(UIPanGestureRecognizer *)recognizer;
- (CATransform3D)transform3D;
Expand Down Expand Up @@ -93,13 +93,7 @@ - (void)addGestureRecognizers
}

- (void)poke {
POPSpringAnimation *rotationAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerRotationX];
rotationAnimation.velocity = @(5);
rotationAnimation.springBounciness = 18.0f;
rotationAnimation.dynamicsMass = 4.0f;
rotationAnimation.dynamicsTension = 200;
rotationAnimation.toValue = @(0);
[self.topView.layer pop_addAnimation:rotationAnimation forKey:@"rotationAnimation"];
[self rotateToOriginWithVelocity:5];
}

- (void)handlePan:(UIPanGestureRecognizer *)recognizer
Expand All @@ -121,13 +115,16 @@ - (void)handlePan:(UIPanGestureRecognizer *)recognizer

if (recognizer.state == UIGestureRecognizerStateEnded ||
recognizer.state == UIGestureRecognizerStateCancelled) {
[self rotateToOrigin];
[self rotateToOriginWithVelocity:0];
}
}

- (void)rotateToOrigin
- (void)rotateToOriginWithVelocity:(CGFloat)velocity
{
POPSpringAnimation *rotationAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerRotationX];
if (velocity > 0) {
rotationAnimation.velocity = @(velocity);
}
rotationAnimation.springBounciness = 18.0f;
rotationAnimation.dynamicsMass = 2.0f;
rotationAnimation.dynamicsTension = 200;
Expand Down

0 comments on commit b361122

Please sign in to comment.