Przeglądaj źródła

Notify the delegate after loop plays to the end

Logan Shire 4 lat temu
rodzic
commit
2635507c6a
1 zmienionych plików z 7 dodań i 0 usunięć
  1. 7 0
      Sources/Views/AnimatedImageView.swift

+ 7 - 0
Sources/Views/AnimatedImageView.swift

@@ -573,12 +573,19 @@ extension AnimatedImageView {
         }
 
         private func incrementCurrentFrameIndex() {
+            let wasLastFrame = isLastFrame
             currentFrameIndex = increment(frameIndex: currentFrameIndex)
             if isLastFrame {
                 currentRepeatCount += 1
                 if isReachMaxRepeatCount {
                     isFinished = true
+
+                    // Notify the delegate here because the animation is stopping.
+                    delegate?.animator(self, didPlayAnimationLoops: currentRepeatCount)
                 }
+            } else if wasLastFrame {
+
+                // Notify the delegate that the loop completed
                 delegate?.animator(self, didPlayAnimationLoops: currentRepeatCount)
             }
         }