0

I'm using the Facebook Pop library to bounce a view every time something happens in my app. The problem is that the animation works only on the 1st occurrence.

It is easily reproducible with this snippet

- (IBAction)buttonAction:(id)sender
{
    POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];
    sprintAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.9, 0.9)];
    sprintAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(2, 2)];
    sprintAnimation.springBounciness = 20.f;

    [self.shakeView pop_addAnimation:sprintAnimation forKey:@"springAnimation"];
}

The 1st time you tap the button, shakeView is animated correctly but not on the taps after.

I tried removing all animation using [self.shakeView pop_removeAllAnimations] before adding a new one but it doesn't help.

I think I missed something in the Pop usage.

Jan
  • 7,444
  • 9
  • 50
  • 74

1 Answers1

1

Ok I found the problem. The solution is to set the removedOnCompletion to NO as follows:

- (IBAction)buttonAction:(id)sender
{

    POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];
    sprintAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.9, 0.9)];
    sprintAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(2, 2)];
    sprintAnimation.springBounciness = 20.f;

    sprintAnimation.removedOnCompletion = NO;

    [self.shakeView pop_addAnimation:sprintAnimation forKey:@"springAnimation"];
}
Jan
  • 7,444
  • 9
  • 50
  • 74