소스 검색

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 년 전
부모
커밋
8b3d27c17b
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      Sources/AnimatedImageView.swift

+ 1 - 1
Sources/AnimatedImageView.swift

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