Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the number of times the animation repeats #1247

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lottie-ios/Classes/Private/LOTAnimationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ - (void)_commonInit {
_animationSpeed = 1;
_animationProgress = 0;
_loopAnimation = NO;
_repeatCount = 1;
_autoReverseAnimation = NO;
_playRangeEndFrame = nil;
_playRangeStartFrame = nil;
Expand All @@ -158,6 +159,7 @@ - (void)_commonInit {
_animationSpeed = 1;
_animationProgress = 0;
_loopAnimation = NO;
_repeatCount = 1;
_autoReverseAnimation = NO;
_playRangeEndFrame = nil;
_playRangeStartFrame = nil;
Expand Down Expand Up @@ -412,7 +414,7 @@ - (void)playFromFrame:(nonnull NSNumber *)fromStartFrame
animation.toValue = toEndFrame;
animation.duration = duration;
animation.fillMode = kCAFillModeBoth;
animation.repeatCount = _loopAnimation ? HUGE_VALF : 1;
animation.repeatCount = _loopAnimation || _repeatCount < 0 ? HUGE_VALF :_repeatCount;
animation.autoreverses = _autoReverseAnimation;
animation.delegate = self;
animation.removedOnCompletion = NO;
Expand Down
3 changes: 3 additions & 0 deletions lottie-ios/Classes/PublicHeaders/LOTAnimationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ typedef void (^LOTAnimationCompletionBlock)(BOOL animationFinished);
/// Tells the animation to loop indefinitely. Defaults to NO.
@property (nonatomic, assign) BOOL loopAnimation;

// Number of times the animation plays in a loop. Defaults to 1y
@property (nonatomic, assign) CGFloat repeatCount;

/// The animation will play forward and then backwards if loopAnimation is also YES
@property (nonatomic, assign) BOOL autoReverseAnimation;

Expand Down