Browse Source

Fix wrong repeatCount calculation in AnimatedImageView

onevcat 6 years ago
parent
commit
5d96c27aae
1 changed files with 4 additions and 7 deletions
  1. 4 7
      Sources/Views/AnimatedImageView.swift

+ 4 - 7
Sources/Views/AnimatedImageView.swift

@@ -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
@@ -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)
             }
         }
@@ -612,5 +611,3 @@ class SafeArray<Element> {
     }
 }
 #endif
-
-#endif