Explorar o código

Notify the delegate after loop plays to the end

Logan Shire %!s(int64=4) %!d(string=hai) anos
pai
achega
2635507c6a
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  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)
             }
         }