Closed batkru closed 9 years ago
Looks good! The only issue i have is the check for wether or not the deletion should occur.
it was previously
if (!shouldDelete || gesture.state == UIGestureRecognizerStateFailed
|| gesture.state == UIGestureRecognizerStateCancelled) {
[self cancelSwipeToDeleteWithCompletion:completionBlock];
}else{
NSArray *indexPathsToDelete = @[selectedIndexPath];
[self performSwipeToDeleteForCellsAtIndexPaths:indexPathsToDelete withCompletion:completionBlock];
}
and now
if (!shouldDelete || gesture.state == UIGestureRecognizerStateFailed ||
gesture.state == UIGestureRecognizerStateCancelled ||
[self translationValue] < self.deletionDistanceTresholdValue ||
[self velocityMagnitude] < self.deletionVelocityTresholdValue ||
[self velocity] > 0) {
[self cancelSwipeToDeleteWithCompletion:completionBlock];
}else{
NSArray *indexPathsToDelete = @[selectedIndexPath];
[self performSwipeToDeleteForCellsAtIndexPaths:indexPathsToDelete withCompletion:completionBlock];
}
i don't think the extra checks are necessary.
[self translationValue] < self.deletionDistanceTresholdValue ||
[self velocityMagnitude] < self.deletionVelocityTresholdValue ||
[self velocity] > 0
see how 'shouldDelete' is setup
userTriggerredSwipeToDeleteDirection = [self deletionDirectionWithGestureRecogniser:gesture];
BOOL shouldDelete = (userTriggerredSwipeToDeleteDirection != LSSwipeToDeleteDirectionNone);
also look at the implementation of the method below
- (void)deletionDirectionWithGestureRecogniser;
I added certain additional validations in regards to whether the deletion should happen as well as fixing a bug of calling deleting index too soon.