|
|
@@ -32,8 +32,21 @@ private let sharedProcessingQueue: CallbackQueue =
|
|
|
|
|
|
public struct ImageProgressive {
|
|
|
|
|
|
+ /// The updating strategy when an intermediate progressive image is generated and about to be set to the hosting view.
|
|
|
+ ///
|
|
|
+ /// - default: Use the progressive image as it is. It is the standard behavior when handling the progressive image.
|
|
|
+ /// - keepCurrent: Discard this progressive image and keep the current displayed one.
|
|
|
+ /// - replace: Replace the image to a new one. If the progressive loading is initialized by a view extension in
|
|
|
+ /// Kingfisher, the replacing image will be used to update the view.
|
|
|
+ public enum UpdatingStrategy {
|
|
|
+ case `default`
|
|
|
+ case keepCurrent
|
|
|
+ case replace(KFCrossPlatformImage?)
|
|
|
+ }
|
|
|
+
|
|
|
/// A default `ImageProgressive` could be used across. It blurs the progressive loading with the fastest
|
|
|
/// scan enabled and scan interval as 0.
|
|
|
+ @available(*, deprecated, message: "Getting a default `ImageProgressive` is deprecated due to its syntax symatic is not clear. Use `ImageProgressive.init` instead.", renamed: "init()")
|
|
|
public static let `default` = ImageProgressive(
|
|
|
isBlur: true,
|
|
|
isFastestScan: true,
|
|
|
@@ -47,6 +60,22 @@ public struct ImageProgressive {
|
|
|
/// Minimum time interval for each scan
|
|
|
let scanInterval: TimeInterval
|
|
|
|
|
|
+ /// Called when an intermediate image is prepared and about to be set to the image view. The return value of this
|
|
|
+ /// delegate will be used to update the hosting view, if any. Otherwise, if there is no hosting view (a.k.a the
|
|
|
+ /// image retrieving is not happening from a view extension method), the returned `UpdatingStrategy` is ignored.
|
|
|
+ public let onImageUpdated = Delegate<KFCrossPlatformImage, UpdatingStrategy>()
|
|
|
+
|
|
|
+ /// Creates an `ImageProgressive` value with default sets. It blurs the progressive loading with the fastest
|
|
|
+ /// scan enabled and scan interval as 0.
|
|
|
+ public init() {
|
|
|
+ self.init(isBlur: true, isFastestScan: true, scanInterval: 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ /// Creates an `ImageProgressive` value the given values.
|
|
|
+ /// - Parameters:
|
|
|
+ /// - isBlur: Whether to enable blur effect processing.
|
|
|
+ /// - isFastestScan: Whether to enable the fastest scan.
|
|
|
+ /// - scanInterval: Minimum time interval for each scan.
|
|
|
public init(isBlur: Bool,
|
|
|
isFastestScan: Bool,
|
|
|
scanInterval: TimeInterval
|