Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions JellyGif/Source/JellyGifAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

///Methods for managing JellyGifAnimator
public protocol JellyGifAnimatorDelegate: class {
public protocol JellyGifAnimatorDelegate: AnyObject {
func gifAnimatorIsReady(_ sender: JellyGifAnimator)

///Registers an UIImageView to display GIF frames
Expand Down Expand Up @@ -113,8 +113,8 @@ public class JellyGifAnimator {
self?.preparingOperation = nil
}

JellyGifAnimator.gifQueue.async {
self.preparingOperation?.start()
JellyGifAnimator.gifQueue.async { [weak self] in
self?.preparingOperation?.start()
}
}

Expand Down
13 changes: 9 additions & 4 deletions JellyGif/Source/JellyGifOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
import UIKit

///An operation object used to prepare information needed to start GIF animation
public class JellyGifOperation: Operation {
public class JellyGifOperation {
public let inputInfo: GifInfo
public let pixelSize: GifPixelSize
public var completionHandler: ([UIImage], [CFTimeInterval]) -> Void

private var isCancelled = false

public init(info: GifInfo, pixelSize: GifPixelSize,
completion: @escaping ([UIImage], [CFTimeInterval]) -> Void) {
self.inputInfo = info
self.pixelSize = pixelSize
self.completionHandler = completion
super.init()
}

override public func main() {
guard isCancelled == false else { return }
public func start() {
guard self.isCancelled == false else { return }

let imageSource = CGImageSource.sourceFromInfo(inputInfo)
let frames = imageSource?.frameDurations ?? []
Expand All @@ -41,4 +42,8 @@ public class JellyGifOperation: Operation {
self?.completionHandler(images, frames)
}
}

public func cancel() {
self.isCancelled = true
}
}