Skip to content

Commit

Permalink
Merge pull request onevcat#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 e031cea + 5d96c27 commit 9ceea64
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 9ceea64

Please sign in to comment.