Skip to content

Commit

Permalink
Improve completions
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Mar 20, 2016
1 parent bdb3e8a commit 29d5c0c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,8 @@ - (void)setSwipeOffset:(CGFloat) newOffset;
if(activeSettings.disableSwipeBounces) {
CGFloat maxOffset = sign * activeButtons.bounds.size.width;
_swipeOffset = sign > 0 ? MIN(newOffset, maxOffset) : MAX(newOffset, maxOffset);
} else {
}
else {
_swipeOffset = newOffset;
}
CGFloat offset = fabs(_swipeOffset);
Expand Down Expand Up @@ -1093,6 +1094,7 @@ -(void) animationTick: (CADisplayLink *) timer
_displayLink = nil;
if (_animationCompletion) {
_animationCompletion();
_animationCompletion = nil;
}
}
}
Expand All @@ -1104,20 +1106,27 @@ -(void) setSwipeOffset:(CGFloat)offset animated: (BOOL) animated completion:(voi

-(void) setSwipeOffset:(CGFloat)offset animation: (MGSwipeAnimation *) animation completion:(void(^)()) completion
{
if (offset !=0) {
[self createSwipeViewIfNeeded];
}
_animationCompletion = completion;
if (_displayLink) {
[_displayLink invalidate];
_displayLink = nil;
}
if (_animationCompletion) { //finish pending animation callback
_animationCompletion();
_animationCompletion = nil;
}
if (offset !=0) {
[self createSwipeViewIfNeeded];
}

if (!animation) {
self.swipeOffset = offset;
if (completion) {
completion();
}
return;
}

_animationCompletion = completion;
_triggerStateChanges = NO;
_animationData.from = _swipeOffset;
_animationData.to = offset;
Expand Down

0 comments on commit 29d5c0c

Please sign in to comment.