Created
May 2, 2014 23:59
-
-
Save rounak/ea9eb450367bd6badf3c to your computer and use it in GitHub Desktop.
Portion of the code that does the deceleration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//get velocity from pan gesture | |
CGPoint velocity = [panGestureRecognizer velocityInView:self]; | |
if (self.bounds.size.width >= self.contentSize.width) { | |
//make movement zero along x if no horizontal scrolling | |
velocity.x = 0; | |
} | |
if (self.bounds.size.height >= self.contentSize.height) { | |
//make movement zero along y if no vertical scrolling | |
velocity.y = 0; | |
} | |
//we need the negative velocity of what we get from the pan gesture, so flip the signs | |
velocity.x = -velocity.x; | |
velocity.y = -velocity.y; | |
POPDecayAnimation *decayAnimation = [POPDecayAnimation animationWithPropertyNamed:kPOPViewBounds]; | |
//last two components zero as we do not want to change bound's size | |
decayAnimation.velocity = [NSValue valueWithCGRect:CGRectMake(velocity.x, velocity.y, 0, 0)]; | |
[self pop_addAnimation:decayAnimation forKey:@"decelerate"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment