Skip to content

Commit

Permalink
replaces 0-delay animation blocks with more lightweight CATransaction.
Browse files Browse the repository at this point in the history
Fixes invalid pragma's
  • Loading branch information
steipete committed Jan 12, 2012
1 parent a23c8f9 commit 22ec389
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions GMGridView/GMGridView.m
Expand Up @@ -280,6 +280,13 @@ - (void)dealloc
#pragma mark Layout
//////////////////////////////////////////////////////////////

- (void)applyWithoutAnimation:(void (^)(void))animations {
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
animations();
[CATransaction commit];
}

- (void)layoutSubviewsWithAnimation:(GMGridViewItemAnimation)animation
{
[self recomputeSizeAnimated:!(animation & GMGridViewItemAnimationNone)];
Expand Down Expand Up @@ -337,14 +344,9 @@ - (void)layoutSubviews
transition.type = kCATransitionFade;
[_scrollView.layer addAnimation:transition forKey:@"rotationAnimation"];

[UIView animateWithDuration:0
delay:0
options:UIViewAnimationOptionOverrideInheritedDuration
animations:^{
[self layoutSubviewsWithAnimation:GMGridViewItemAnimationNone];
}
completion:nil
];
[self applyWithoutAnimation:^{
[self layoutSubviewsWithAnimation:GMGridViewItemAnimationNone];
}];
}
else
{
Expand Down Expand Up @@ -1143,15 +1145,11 @@ - (GMGridViewCell *)newItemSubViewForPosition:(NSInteger)position
CGRect frame = CGRectMake(origin.x, origin.y, _itemSize.width, _itemSize.height);

// To make sure the frame is not animated
[UIView animateWithDuration:0
delay:0
options:kDefaultAnimationOptions | UIViewAnimationOptionOverrideInheritedDuration
animations:^{
cell.frame = frame;
cell.contentView.frame = cell.bounds;
}
completion:nil];

[self applyWithoutAnimation:^{
cell.frame = frame;
cell.contentView.frame = cell.bounds;
}];

cell.tag = position + kTagOffset;
BOOL canEdit = self.editing && [self.dataSource GMGridView:self canDeleteItemAtIndex:position];
[cell setEditing:canEdit animated:NO];
Expand Down

0 comments on commit 22ec389

Please sign in to comment.