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

Added a loop completion block #60

Closed
wants to merge 3 commits into from
Closed

Added a loop completion block #60

wants to merge 3 commits into from

Conversation

delannoyk
Copy link
Contributor

No description provided.

* Added a completion block on FLAnimatedImageView that is executed when a loop is finished
* Updated example to user loopCompletionBlock
@@ -259,6 +259,10 @@ - (void)displayDidRefresh:(CADisplayLink *)displayLink
if (self.currentFrameIndex >= self.animatedImage.frameCount) {
// If we've looped the number of times that this animated image describes, stop looping.
self.loopCountdown--;
if (self.loopCompletionBlock) {
self.loopCompletionBlock(self, self.loopCountdown);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there the chance to run into a retain-cycle here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how. But I'm not sure of the benefits to pass itself as a parameter anyway. I added it in case any other dev that would use this feature would need it.

@raphaelschaad
Copy link
Collaborator

Hey! Thanks for your pull request! I left some detailed feedback inline.

What were you using this feature for? What's the use case?

I'm also curious whether it would not make sense to follow the general delegate pattern that the project is already using.

@raphaelschaad raphaelschaad mentioned this pull request Jan 17, 2015
@delannoyk
Copy link
Contributor Author

Hi Raphael,

Thanks for your feedbacks, I'll look into them ASAP and change what needs to be changed :-)

My use case is pretty simple : a client of mine asked for a GIF as splash screen. So when one cycle has been made, I just "open the real app".

Thanks,
Kevin

* LoopCompletionBlock doesn't pass the imageView as parameter anymore
* loopLeft parameter became loopCountRemaining
* Removed usage demo in example project
@delannoyk
Copy link
Contributor Author

Hi Raphael,

I made a few changes.

Also,

I'm also curious whether it would not make sense to follow the general delegate pattern that the project is already using.

I didn't use the delegate pattern already created because it's marked as intended for debugging purpose (for both FLAnimatedImageDebugDelegate and FLAnimatedImageViewDebugDelegate) and I didn't want to change that. In my case, I needed it in release.

@marcferna
Copy link

👍

@7hacker
Copy link

7hacker commented Nov 18, 2015

Hi, this is incredibly useful! but Im not following how I can use the loop completion block to run my animation only once
can someone provide an example how to use the loop completion block

@timonus
Copy link
Contributor

timonus commented Nov 30, 2015

LGTM!

@timonus
Copy link
Contributor

timonus commented Nov 30, 2015

Rebased with the current master and merged at 9268e8c. Thanks!

@timonus timonus closed this Nov 30, 2015
@delannoyk
Copy link
Contributor Author

Great! Thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants