So I have a very good implementation of panning on a tableview cell. I basically use panGestureRecognizer and move the cell off screen, and show another view below the tableViewCell. This is working fine. When I pan on the tableViewCell, I basically reveal 5 buttons underneath.
My goal is to animate the 5 buttons as the tableviewcell is moving. For example,
| 1 | 2 | 3 | 4 | 5|
If I am swiping, and moving the cell right and I am cross button 1, I will animate button popping out and become visible to the user. If I am crossing 2, then 2 will animate popping out, and become visible to the user. And when I am in button 5, all buttons are already popped and ready for user actions.
I am doing this with
//Scale Animation
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.duration = 0.3;
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1,0.1, 1.0)];
scaleAnim.removedOnCompletion = YES;
[view.layer addAnimation:scaleAnim forKey:nil];
**
My goal :
**
So when I am in the middle of a panning gesture, and I decide to close it ( move to the left), the buttons should pop-in, and become unavailable to the user.
Also, as I move the cell the button should gradually scale up, and become available to the user. So I will essentially need to pass the cell's origin and use some math to compute the scale for the buttons based on the button's origin and width (fairly straight-forward).
if (CGRectIntersectsRect(button.frame, self.movingCell.frame))
{
CGFloat xScale = cellTranslation - xOriginForButton;
[self popOutAnimate:button withScale:xScale/ (xWidthForButtons + xSpaceBetweenButtons)];
}
But the problem comes up when I move the cell really fast, the views don't get all the changes in cell's movement and they are stuck in a half animated state.
I have a feeling that I am not grasping the logic right. The whole implementation is similar to the Sparrow iphone mail app. When you pan on the cell, the buttons reveal with animation as the cell is moved. For those who have not used sparrow. You can see the panning gesture in 1:25 https://www.youtube.com/watch?v=XLX6XV0SbWI&t=1m25s
Is the logic correct? Am I missing something?
Any help is much appreciated.