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
Using the isAnimating arg, instead of protocol extention method to control the WebImage's animation supports. This allows the binding control for animation as well
Copy file name to clipboardExpand all lines: SDWebImageSwiftUI/Classes/WebImage.swift
+46-51Lines changed: 46 additions & 51 deletions
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,10 @@ 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,6 +33,23 @@ public struct WebImage : View {
31
33
/// - Parameter options: The options to use when downloading the image. See `SDWebImageOptions` for the possible values.
32
34
/// - 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.
40
+
/// - Parameter url: The image url
41
+
/// - Parameter options: The options to use when downloading the image. See `SDWebImageOptions` for the possible values.
42
+
/// - 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.
43
+
/// - 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.
233
-
///
234
-
/// - Parameter animated: Whether or not to enable animationn.
0 commit comments