Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add force transition option #317

Merged
merged 1 commit into from
May 10, 2016
Merged
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
4 changes: 2 additions & 2 deletions Sources/ImageView+Kingfisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ extension ImageView {
return
}

if let transitionItem = optionsInfo?.kf_firstMatchIgnoringAssociatedValue(.Transition(.None)),
case .Transition(let transition) = transitionItem where cacheType == .None {
if let transitionItem = options.kf_firstMatchIgnoringAssociatedValue(.Transition(.None)),
case .Transition(let transition) = transitionItem where ( options.forceTransition || cacheType == .None) {
#if !os(OSX)
UIView.transitionWithView(sSelf, duration: 0.0, options: [],
animations: {
Expand Down
9 changes: 8 additions & 1 deletion Sources/KingfisherOptionsInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ Items could be added into KingfisherOptionsInfo.

- TargetCache: The associated value of this member should be an ImageCache object. Kingfisher will use the specified cache object when handling related operations, including trying to retrieve the cached images and store the downloaded image to it.
- Downloader: The associated value of this member should be an ImageDownloader object. Kingfisher will use this downloader to download the images.
- Transition: Member for animation transition when using UIImageView. Kingfisher will use the `ImageTransition` of this enum to animate the image in if it is downloaded from web. The transition will not happen when the image is retrieved from either memory or disk cache.
- Transition: Member for animation transition when using UIImageView. Kingfisher will use the `ImageTransition` of this enum to animate the image in if it is downloaded from web. The transition will not happen when the image is retrieved from either memory or disk cache by default. If you need to do the transition even when the image being retrieved from cache, set `ForceTransition` as well.
- DownloadPriority: Associated `Float` value will be set as the priority of image download task. The value for it should be between 0.0~1.0. If this option not set, the default value (`NSURLSessionTaskPriorityDefault`) will be used.
- ForceRefresh: If set, `Kingfisher` will ignore the cache and try to fire a download task for the resource.
- ForceTransition: If set, setting the image to an image view will happen with transition even when retrieved from cache. See `Transition` option for more.
- CacheMemoryOnly: If set, `Kingfisher` will only cache the value in memory but not in disk.
- BackgroundDecode: Decode the image in background thread before using.
- CallbackDispatchQueue: The associated value of this member will be used as the target queue of dispatch callbacks when retrieving images from cache. If not set, `Kingfisher` will use main quese for callbacks.
Expand All @@ -57,6 +58,7 @@ public enum KingfisherOptionsInfoItem {
case Transition(ImageTransition)
case DownloadPriority(Float)
case ForceRefresh
case ForceTransition
case CacheMemoryOnly
case BackgroundDecode
case CallbackDispatchQueue(dispatch_queue_t?)
Expand All @@ -77,6 +79,7 @@ func <== (lhs: KingfisherOptionsInfoItem, rhs: KingfisherOptionsInfoItem) -> Boo
case (.Transition(_), .Transition(_)): fallthrough
case (.DownloadPriority(_), .DownloadPriority(_)): fallthrough
case (.ForceRefresh, .ForceRefresh): fallthrough
case (.ForceTransition, .ForceTransition): fallthrough
case (.CacheMemoryOnly, .CacheMemoryOnly): fallthrough
case (.BackgroundDecode, .BackgroundDecode): fallthrough
case (.CallbackDispatchQueue(_), .CallbackDispatchQueue(_)): fallthrough
Expand Down Expand Up @@ -138,6 +141,10 @@ extension CollectionType where Generator.Element == KingfisherOptionsInfoItem {
return contains{ $0 <== .ForceRefresh }
}

var forceTransition: Bool {
return contains{ $0 <== .ForceTransition }
}

var cacheMemoryOnly: Bool {
return contains{ $0 <== .CacheMemoryOnly }
}
Expand Down