Skip to content

Make loopCount writable so one can set the animation loop count #83

Closed
@0x7061

Description

@0x7061

Hey guys,

first of all great library! I have the scenario where I want to be able to animate a GIF only once but I don't want to modify the GIF because on other places I do want the infinitive loop.

I found the loopCount property on FLAnimatedImage which when I modify the readonly flag and set it to 1 gives me exactly the outcome I want.

Is it possible to make it writable without me having to fork it?

Activity

added a commit that references this issue on Aug 19, 2015
f508b8f
raphaelschaad

raphaelschaad commented on Aug 20, 2015

@raphaelschaad
Collaborator

Hi – thanks for opening this issue.

I'm not convinced yet that making the immutable properties of a GIF writable is the best way to go. Consequently, the same would have to happen e.g. with delay times.

Here is an approach with a loop completion block: https://github.com/Flipboard/FLAnimatedImage/pull/60/files

I'll think more about it. Any input is welcome!

cemo

cemo commented on Aug 20, 2015

@cemo

#60 seems like a natural fit. Any chance to merge it?

x1024

x1024 commented on May 18, 2016

@x1024

I would second making the loop count and delay times writable. I tried several different methods to make a gif not loop. It works in a browser, but not in FLAnimatedImage.
I'm not placing any blame in FLAnimatedImage, because GIF is perhaps a more complex standard than is reasonable.

But it would save a great deal of hair-pulling if I could just set an integer property, instead of wrestling with command-line tools that cater to an arcane spec.

dalu93

dalu93 commented on Jun 13, 2016

@dalu93

+1

@x1024 I solved with a simple workaround. After each loop is finished, it calls the loopCompletionBlock on the FLAnimatedImageView instance. I have simply implemented it like

private func finishedLoop(remainingLoops: UInt) {

    imageView.stopAnimating()
}
dharmendrajadav

dharmendrajadav commented on Sep 26, 2016

@dharmendrajadav

@dalu93 How to use loopCompletionBlock in swift 3?

DuongQuangLoc

DuongQuangLoc commented on Oct 28, 2016

@DuongQuangLoc

@dalu93
In swift 3
self.imageView.loopCompletionBlock = { (uint: UInt) -> Void in
// unit is the loop time of image.
self.imageView.stopAnimating()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @cemo@x1024@raphaelschaad@timonus@0x7061

      Issue actions

        Make loopCount writable so one can set the animation loop count · Issue #83 · Flipboard/FLAnimatedImage