Browse Source

Fixes off-by-one-error

This commit fixes an issue in which (when the frameCount is larger than the number of frames) a frame would be skipped when looping back to the beginning of the buffer
Michael Liberatore 8 years ago
parent
commit
8b3d27c17b
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Sources/AnimatedImageView.swift

+ 1 - 1
Sources/AnimatedImageView.swift

@@ -380,7 +380,7 @@ class Animator {
         let frameToProcess = min(frameCount, maxFrameCount)
         animatedFrames.reserveCapacity(frameToProcess)
         animatedFrames = (0..<frameToProcess).reduce([]) { $0 + pure(prepareFrame(at: $1))}
-        currentPreloadIndex = (frameToProcess + 1) % frameCount
+        currentPreloadIndex = (frameToProcess + 1) % frameCount - 1
     }
     
     private func prepareFrame(at index: Int) -> AnimatedFrame {