├── .gitignore ├── .swiftpm └── xcode │ └── package.xcworkspace │ └── contents.xcworkspacedata ├── LICENSE ├── Package.resolved ├── Package.swift ├── README.md └── Source └── AnimatedImage.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | xcshareddata 14 | *.xccheckout 15 | *.moved-aside 16 | DerivedData 17 | *.hmap 18 | *.ipa 19 | *.xcuserstate 20 | 21 | # CocoaPods 22 | # 23 | # We recommend against adding the Pods directory to your .gitignore. However 24 | # you should judge for yourself, the pros and cons are mentioned at: 25 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 26 | # 27 | Pods/ 28 | 29 | # Carthage 30 | # 31 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 32 | 33 | Carthage/Checkouts 34 | Carthage/Build 35 | 36 | .swiftpm 37 | .build -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2021 Alexander Grebenyuk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "FLAnimatedImage", 6 | "repositoryURL": "https://github.com/Flipboard/FLAnimatedImage", 7 | "state": { 8 | "branch": null, 9 | "revision": "e7f9fd4681ae41bf6f3056db08af4f401d61da52", 10 | "version": "1.0.16" 11 | } 12 | }, 13 | { 14 | "package": "Nuke", 15 | "repositoryURL": "https://github.com/kean/Nuke.git", 16 | "state": { 17 | "branch": null, 18 | "revision": "5a8d11b4b8fd631f2937d2e41910ae329aed31b7", 19 | "version": "10.0.0" 20 | } 21 | } 22 | ] 23 | }, 24 | "version": 1 25 | } 26 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "NukeFLAnimatedImagePlugin", 6 | platforms: [ 7 | .iOS(.v11), 8 | .tvOS(.v11) 9 | ], 10 | products: [ 11 | .library(name: "NukeFLAnimatedImagePlugin", targets: ["NukeFLAnimatedImagePlugin"]), 12 | ], 13 | dependencies: [ 14 | .package( 15 | url: "https://github.com/kean/Nuke.git", 16 | from: "10.0.0" 17 | ), 18 | .package( 19 | url: "https://github.com/Flipboard/FLAnimatedImage", 20 | .upToNextMajor(from: "1.0.0") 21 | ) 22 | ], 23 | targets: [ 24 | .target(name: "NukeFLAnimatedImagePlugin", dependencies: ["Nuke", "FLAnimatedImage"], path: "Source") 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) plugin for [Nuke](https://github.com/kean/Nuke) that allows you to load and display animated GIFs with [smooth scrolling performance](https://www.youtube.com/watch?v=fEJqQMJrET4) and low memory footprint. You can see it for yourself in a demo, included in the project. 4 | 5 | ## Usage 6 | 7 | All you need to do to enable GIF support is set `isAnimatedImageDataEnabled` to `true`. After you do that, you can start using `FLAnimatedImageView`. 8 | 9 | ```swift 10 | let view = FLAnimatedImageView() 11 | Nuke.loadImage(with: URL(string: "http://.../cat.gif")!, into: view) 12 | ``` 13 | 14 | ## Minimum Requirements 15 | 16 | | Nuke FLAnimatedImage Plugin | Swift | Xcode | Platforms | 17 | |----------------------------------------|-----------------------|----------------------|-------------| 18 | | Nuke FLAnimatedImage Plugin 8.0 | Swift 5.3 | Xcode 12.0 | iOS 11.0 / tvOS 11.0 | 19 | | Nuke FLAnimatedImage Plugin 7.0 | Swift 5.1 | Xcode 11.0 | iOS 11.0 | 20 | 21 | ## Dependencies 22 | 23 | - [Nuke ~> 10.0](https://github.com/kean/Nuke) 24 | - [FLAnimatedImage ~> 1.0](https://github.com/Flipboard/FLAnimatedImage) 25 | 26 | ## License 27 | 28 | Nuke is available under the MIT license. See the LICENSE file for more info. 29 | -------------------------------------------------------------------------------- /Source/AnimatedImage.swift: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2016-2021 Alexander Grebenyuk (github.com/kean). 4 | 5 | import UIKit 6 | import FLAnimatedImage 7 | import Nuke 8 | 9 | extension FLAnimatedImageView { 10 | open override func nuke_display(image: UIImage?, data: Data?) { 11 | guard image != nil else { 12 | self.animatedImage = nil 13 | self.image = nil 14 | return 15 | } 16 | if let data = data { 17 | // Display poster image immediately 18 | self.image = image 19 | 20 | // Prepare FLAnimatedImage object asynchronously (it takes a 21 | // noticeable amount of time), and start playback. 22 | DispatchQueue.global().async { 23 | let animatedImage = FLAnimatedImage(animatedGIFData: data) 24 | DispatchQueue.main.async { 25 | // If view is still displaying the same image 26 | if self.image === image { 27 | self.animatedImage = animatedImage 28 | } 29 | } 30 | } 31 | } else { 32 | self.image = image 33 | } 34 | } 35 | } 36 | --------------------------------------------------------------------------------