Skip to content

Commit

Permalink
Merge pull request MortimerGoro#242 from mirego/master
Browse files Browse the repository at this point in the history
Fix glitch when dragging before animation completes
  • Loading branch information
MortimerGoro authored Jun 17, 2017
2 parents c10630b + d169885 commit 48b4972
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -1130,14 +1130,20 @@ -(void) animationTick: (CADisplayLink *) timer
//call animation completion and invalidate timer
if (completed){
[timer invalidate];
_displayLink = nil;
if (_animationCompletion) {
void (^callbackCopy)(BOOL finished) = _animationCompletion; //copy to avoid duplicated callbacks
_animationCompletion = nil;
callbackCopy(YES);
}
[self invalidateDisplayLink];
}
}

-(void)invalidateDisplayLink {
[_displayLink invalidate];
_displayLink = nil;
if (_animationCompletion) {
void (^callbackCopy)(BOOL finished) = _animationCompletion; //copy to avoid duplicated callbacks
_animationCompletion = nil;
callbackCopy(YES);
}
}

-(void) setSwipeOffset:(CGFloat)offset animated: (BOOL) animated completion:(void(^)(BOOL finished)) completion
{
MGSwipeAnimation * animation = animated ? [[MGSwipeAnimation alloc] init] : nil;
Expand Down Expand Up @@ -1223,6 +1229,8 @@ -(void) panHandler: (UIPanGestureRecognizer *)gesture
CGPoint current = [gesture translationInView:self];

if (gesture.state == UIGestureRecognizerStateBegan) {
[self invalidateDisplayLink];

if (!_preservesSelectionStatus)
self.highlighted = NO;
[self createSwipeViewIfNeeded];
Expand Down

0 comments on commit 48b4972

Please sign in to comment.