Skip to content

Commit

Permalink
Found a better way to fix issue MortimerGoro#37 : Right expansion ani…
Browse files Browse the repository at this point in the history
…mation not working properly
  • Loading branch information
MortimerGoro committed Nov 16, 2014
1 parent 9d78338 commit 7424bc9
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,12 @@ -(void) expandToOffset:(CGFloat) offset button:(NSInteger) index
CGRect previusRect = _container.frame;
[self layoutExpansion:offset];
[self resetButtons];
if (!_fromLeft && index == _buttons.count - 1) { //Fix expansion animation for the first right button
CGRect frame = _expandedButton.frame;
frame.origin.x += _container.bounds.size.width - previusRect.size.width;
_expandedButton.frame = frame;
}
for (int i = 0; i < _buttons.count; ++i) { //hide buttons behind expanded button (useful when the expansion index is not 0)
((UIView*)[_buttons objectAtIndex:i]).hidden = _fromLeft ? i < index : _buttons.count - 1 - i < index;
if (!_fromLeft) { //Fix expansion animation for right buttons
for (UIView * button in _buttons) {
CGRect frame = button.frame;
frame.origin.x += _container.bounds.size.width - previusRect.size.width;
button.frame = frame;
}
}
_expansionBackground = [[UIView alloc] initWithFrame:[self expansionBackgroundRect:_expandedButton]];
_expansionBackground.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Expand All @@ -167,9 +166,6 @@ -(void) expandToOffset:(CGFloat) offset button:(NSInteger) index
_expansionBackground.frame = [self expansionBackgroundRect:_expandedButton];

} completion:^(BOOL finished) {
for (UIView * button in _buttons) {
button.hidden = NO;
}
}];
return;
}
Expand All @@ -186,9 +182,6 @@ -(void) endExpansioAnimated:(BOOL) animated
_expansionBackgroundAnimated = _expansionBackground;
_expansionBackground = nil;
_expandedButton = nil;
for (UIView * button in _buttons) {
button.hidden = NO;
}
CGFloat duration = _fromLeft ? _cell.leftExpansion.animationDuration : _cell.rightExpansion.animationDuration;
[UIView animateWithDuration: animated ? duration : 0.0 animations:^{
_container.frame = self.bounds;
Expand Down

0 comments on commit 7424bc9

Please sign in to comment.