diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 207726e9..d9a8d3e8 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -11,7 +11,7 @@ PODS: - SDWebImage (5.2.3): - SDWebImage/Core (= 5.2.3) - SDWebImage/Core (5.2.3) - - SDWebImageSwiftUI (0.3.1): + - SDWebImageSwiftUI (0.3.2): - SDWebImage (~> 5.1) - SDWebImageWebPCoder (0.2.5): - libwebp (~> 1.0) @@ -34,9 +34,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: libwebp: 057912d6d0abfb6357d8bb05c0ea470301f5d61e SDWebImage: 46a7f73228f84ce80990c786e4372cf4db5875ce - SDWebImageSwiftUI: 1b67183dd2ef0321b2ccf578775de8e47eaceb77 + SDWebImageSwiftUI: a8a03ef596dde2e9668a76794f6c59d194289bb0 SDWebImageWebPCoder: 947093edd1349d820c40afbd9f42acb6cdecd987 PODFILE CHECKSUM: 3fb06a5173225e197f3a4bf2be7e5586a693257a -COCOAPODS: 1.8.3 +COCOAPODS: 1.8.4 diff --git a/SDWebImageSwiftUI/Classes/AnimatedImage.swift b/SDWebImageSwiftUI/Classes/AnimatedImage.swift index e1fdda0a..a7675d72 100644 --- a/SDWebImageSwiftUI/Classes/AnimatedImage.swift +++ b/SDWebImageSwiftUI/Classes/AnimatedImage.swift @@ -129,6 +129,10 @@ public struct AnimatedImage : PlatformViewRepresentable { public func updateNSView(_ nsView: AnimatedImageViewWrapper, context: NSViewRepresentableContext) { updateView(nsView, context: context) } + + public static func dismantleNSView(_ nsView: AnimatedImageViewWrapper, coordinator: ()) { + dismantleView(nsView, coordinator: coordinator) + } #else public func makeUIView(context: UIViewRepresentableContext) -> AnimatedImageViewWrapper { makeView(context: context) @@ -137,6 +141,10 @@ public struct AnimatedImage : PlatformViewRepresentable { public func updateUIView(_ uiView: AnimatedImageViewWrapper, context: UIViewRepresentableContext) { updateView(uiView, context: context) } + + public static func dismantleUIView(_ uiView: AnimatedImageViewWrapper, coordinator: ()) { + dismantleView(uiView, coordinator: coordinator) + } #endif func makeView(context: PlatformViewRepresentableContext) -> AnimatedImageViewWrapper { @@ -175,6 +183,14 @@ public struct AnimatedImage : PlatformViewRepresentable { layoutView(view, context: context) } + static func dismantleView(_ view: AnimatedImageViewWrapper, coordinator: ()) { + #if os(macOS) + view.wrapped.animates = false + #else + view.wrapped.stopAnimating() + #endif + } + func layoutView(_ view: AnimatedImageViewWrapper, context: PlatformViewRepresentableContext) { // AspectRatio if let _ = imageLayout.aspectRatio {