Skip to content

Commit

Permalink
Don't set cell frames as often
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Drayer committed Mar 20, 2012
1 parent 86398f4 commit f2b2133
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions KKGridView/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
#define __kk_weak __unsafe_unretained
#endif

static inline bool KKCGRectIntersectsRectVertically(CGRect rect1, CGRect rect2)
#if !defined(KKInline)
#define KKInline static __inline__ __attribute__((always_inline))
#endif

KKInline BOOL KKCGRectIntersectsRectVertically(CGRect rect1, CGRect rect2)
{
return (CGRectGetMinY(rect2) < CGRectGetMaxY(rect1)) && (CGRectGetMaxY(rect2) > CGRectGetMinY(rect1));
}

static inline bool KKCGRectIntersectsRectVerticallyWithPositiveNegativeMargin(CGRect rect1, CGRect rect2, CGFloat margin)
KKInline BOOL KKCGRectIntersectsRectVerticallyWithPositiveNegativeMargin(CGRect rect1, CGRect rect2, CGFloat margin)
{
return (CGRectGetMinY(rect2) - margin < CGRectGetMaxY(rect1)) && (CGRectGetMaxY(rect2) + margin > CGRectGetMinY(rect1));
}
Expand Down
3 changes: 2 additions & 1 deletion KKGridView/KKGridView.m
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ - (void)_cleanupCells
KKGridViewCell *cell = pair.cell;

[self _enqueueCell:cell withIdentifier:cell.reuseIdentifier];
cell.frame = (CGRect){.size = _cellSize};
if (!CGSizeEqualToSize(_cellSize, cell.frame.size))
cell.frame = (CGRect){.size = _cellSize};
cell.hidden = YES;
cell.alpha = 0.;

Expand Down

0 comments on commit f2b2133

Please sign in to comment.