Skip to content

Commit

Permalink
Add ability to synchronize multiple shimmers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ari Greenberg committed May 7, 2015
1 parent f4158b8 commit 08445aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions FBShimmering/FBShimmering.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,11 @@ typedef NS_ENUM(NSInteger, FBShimmerDirection) {
*/
@property (assign, nonatomic, readonly) CFTimeInterval shimmeringFadeTime;

/**
@abstract The absolute CoreAnimation media time when the shimmer will begin.
@discussion Only valid after setting {@ref shimmering} to YES.
*/
@property (assign, nonatomic) CFTimeInterval shimmeringBeginTime;

@end

16 changes: 16 additions & 0 deletions FBShimmering/FBShimmeringLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,22 @@ - (void)setShimmeringOpacity:(CGFloat)shimmeringOpacity
}
}

- (CFTimeInterval)shimmeringBeginTime
{
return [_maskLayer animationForKey:kFBShimmerSlideAnimationKey].beginTime;
}

- (void)setShimmeringBeginTime:(CFTimeInterval)beginTime
{
CAAnimation *slideAnimation = [[_maskLayer animationForKey:kFBShimmerSlideAnimationKey] mutableCopy];
if (nil == slideAnimation) {
return;
}

slideAnimation.beginTime = beginTime;
[_maskLayer addAnimation:slideAnimation forKey:kFBShimmerSlideAnimationKey];
}

- (void)layoutSublayers
{
[super layoutSublayers];
Expand Down
1 change: 1 addition & 0 deletions FBShimmering/FBShimmeringView.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ - (void)mutator (ctype)value { \
LAYER_ACCESSOR(shimmeringFadeTime, CFTimeInterval)
LAYER_RW_PROPERTY(shimmeringBeginFadeDuration, setShimmeringBeginFadeDuration:, CFTimeInterval)
LAYER_RW_PROPERTY(shimmeringEndFadeDuration, setShimmeringEndFadeDuration:, CFTimeInterval)
LAYER_RW_PROPERTY(shimmeringBeginTime, setShimmeringBeginTime:, CFTimeInterval)

- (void)setContentView:(UIView *)contentView
{
Expand Down

0 comments on commit 08445aa

Please sign in to comment.