You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -21,16 +21,42 @@ public struct WebImage : View {
21
21
22
22
@ObservedObjectvarimageManager:ImageManager
23
23
24
-
// Animated Image support (Beta)
25
-
varanimated:Bool=false
24
+
/// A Binding to control the animation. You can bind external logic to control the animation status.
25
+
/// True to start animation, false to stop animation.
26
+
@BindingpublicvarisAnimating:Bool
27
+
26
28
@StatevarcurrentFrame:PlatformImage?=nil
27
29
@StatevarimagePlayer:SDAnimatedImagePlayer?=nil
28
30
31
+
varmaxBufferSize:UInt?
32
+
varcustomLoopCount:UInt?
33
+
varrunLoopMode:RunLoop.Mode=.common
34
+
varpausable:Bool=true
35
+
varpurgeable:Bool=false
36
+
varplaybackRate:Double=1.0
37
+
29
38
/// Create a web image with url, placeholder, custom options and context.
30
39
/// - Parameter url: The image url
31
40
/// - Parameter options: The options to use when downloading the image. See `SDWebImageOptions` for the possible values.
32
41
/// - Parameter context: A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
/// Create a web image with url, placeholder, custom options and context. Optional can support animated image using Binding.
47
+
/// - Parameter url: The image url
48
+
/// - Parameter options: The options to use when downloading the image. See `SDWebImageOptions` for the possible values.
49
+
/// - Parameter context: A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
50
+
/// - Parameter isAnimating: The binding for animation control. The binding value should be `true` when initialized to setup the correct animated image class. If not, you must provide the `.animatedImageClass` explicitly. When the animation started, this binding can been used to start / stop the animation.
/// Make the image to support animated images. The animation will start when view appears, and pause when disappears.
231
-
/// - Note: Currently we do not have advanced control like binding, reset frame index, playback rate, etc. For those use case, it's recommend to use `AnimatedImage` type instead. (support iOS/tvOS/macOS)
232
-
/// - Warning: This API need polishing. In the future we may choose to create a new View type instead.
295
+
/// Total loop count for animated image rendering. Defaults to nil.
296
+
/// - Note: Pass nil to disable customization, use the image itself loop count (`animatedImageLoopCount`) instead
297
+
/// - Parameter loopCount: The animation loop count
/// Provide a max buffer size by bytes. This is used to adjust frame buffer count and can be useful when the decoding cost is expensive (such as Animated WebP software decoding). Default is nil.
233
305
///
234
-
/// - Parameter animated: Whether or not to enable animationn.
/// The runLoopMode when animation is playing on. Defaults is `.common`
317
+
/// You can specify a runloop mode to let it rendering.
318
+
/// - Note: This is useful for some cases, for example, always specify NSDefaultRunLoopMode, if you want to pause the animation when user scroll (for Mac user, drag the mouse or touchpad)
319
+
/// - Parameter runLoopMode: The runLoopMode for animation
/// Whether or not to pause the animation (keep current frame), instead of stop the animation (frame index reset to 0). When `isAnimating` binding value changed to false. Defaults is true.
327
+
/// - Note: For some of use case, you may want to reset the frame index to 0 when stop, but some other want to keep the current frame index.
328
+
/// - Parameter pausable: Whether or not to pause the animation instead of stop the animation.
329
+
publicfunc pausable(_ pausable:Bool)->WebImage{
330
+
varresult=self
331
+
result.pausable = pausable
332
+
return result
333
+
}
334
+
335
+
/// Whether or not to clear frame buffer cache when stopped. Defaults is false.
336
+
/// Note: This is useful when you want to limit the memory usage during frequently visibility changes (such as image view inside a list view, then push and pop)
337
+
/// - Parameter purgeable: Whether or not to clear frame buffer cache when stopped.
338
+
publicfunc purgeable(_ purgeable:Bool)->WebImage{
339
+
varresult=self
340
+
result.purgeable = purgeable
341
+
return result
342
+
}
343
+
344
+
/// Control the animation playback rate. Default is 1.0.
345
+
/// `1.0` means the normal speed.
346
+
/// `0.0` means stopping the animation.
347
+
/// `0.0-1.0` means the slow speed.
348
+
/// `> 1.0` means the fast speed.
349
+
/// `< 0.0` is not supported currently and stop animation. (may support reverse playback in the future)
350
+
/// - Parameter playbackRate: The animation playback rate.
0 commit comments