Skip to content

Commit

Permalink
Merge pull request MortimerGoro#44 from mikeMTOL/master
Browse files Browse the repository at this point in the history
added utility method to expand swipe animation
  • Loading branch information
MortimerGoro committed Jan 9, 2015
2 parents 73f944d + afa528d commit cd2f58f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions MGSwipeTableCell/MGSwipeTableCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ typedef NS_ENUM(NSInteger, MGSwipeState) {
-(void) hideSwipeAnimated: (BOOL) animated;
-(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated;
-(void) setSwipeOffset:(CGFloat)offset animated: (BOOL) animated completion:(void(^)()) completion;
-(void) expandSwipe: (MGSwipeDirection) direction animated: (BOOL) animated;

/** Refresh method to be used when you want to update the cell contents while the user is swipping */
-(void) refreshContentView;
Expand Down
23 changes: 23 additions & 0 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,29 @@ -(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated
}
}

-(void) expandSwipe: (MGSwipeDirection) direction animated: (BOOL) animated
{
CGFloat s = direction == MGSwipeDirectionLeftToRight ? 1.0 : -1.0;
MGSwipeExpansionSettings* expSetting = direction == MGSwipeDirectionLeftToRight ? _leftExpansion : _rightExpansion;

// only perform animation if there's no pending expansion animation and requested direction has fillOnTrigger enabled
if(!_activeExpansion && expSetting.fillOnTrigger) {
[self createSwipeViewIfNeeded];
_allowSwipeLeftToRight = _leftButtons.count > 0;
_allowSwipeRightToLeft = _rightButtons.count > 0;
UIView * buttonsView = direction == MGSwipeDirectionLeftToRight ? _leftView : _rightView;

if (buttonsView) {
__weak typeof(_activeExpansion) w_expantionView = direction == MGSwipeDirectionLeftToRight ? _leftView : _rightView;
__weak typeof(self) weakself = self;
[self setSwipeOffset:buttonsView.bounds.size.width * s * expSetting.threshold * 2 animated:animated completion:^{
[w_expantionView endExpansioAnimated:YES];
[weakself setSwipeOffset:0 animated:NO completion:nil];
}];
}
}
}

-(void) animationTick: (CADisplayLink *) timer
{
if (!_animationData.start) {
Expand Down

0 comments on commit cd2f58f

Please sign in to comment.