Skip to content

Commit

Permalink
Merge pull request #1350 from onevcat/fix/gif-repeat-count
Browse files Browse the repository at this point in the history
Fix wrong repeatCount calculation in AnimatedImageView
  • Loading branch information
onevcat committed Nov 17, 2019
2 parents e951bc2 + 4c848a0 commit a33995f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Sources/Views/AnimatedImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
// The name and characters used in the demo of this software are property of their
// respective owners.

#if !os(watchOS)

#if canImport(UIKit)
import UIKit
import ImageIO
Expand Down Expand Up @@ -534,10 +532,11 @@ extension AnimatedImageView {

private func incrementCurrentFrameIndex() {
currentFrameIndex = increment(frameIndex: currentFrameIndex)
if isReachMaxRepeatCount && isLastFrame {
isFinished = true
} else if currentFrameIndex == 0 {
if isLastFrame {
currentRepeatCount += 1
if isReachMaxRepeatCount {
isFinished = true
}
delegate?.animator(self, didPlayAnimationLoops: currentRepeatCount)
}
}
Expand Down Expand Up @@ -612,5 +611,3 @@ class SafeArray<Element> {
}
}
#endif

#endif

0 comments on commit a33995f

Please sign in to comment.