Skip to content

Commit bd6a9a9

Browse files
authored
Merge pull request #30 from SDWebImage/bufix_animated_image_macOS
Fix that AnimatedImage on macOS can not restart animation after first stop
2 parents 51f3595 + 01c68e1 commit bd6a9a9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ public struct AnimatedImage : PlatformViewRepresentable {
211211
}
212212

213213
func updateView(_ view: AnimatedImageViewWrapper, context: PlatformViewRepresentableContext<AnimatedImage>) {
214+
// macOS SDAnimatedImageView.animates should initialize to true in advance before set image
215+
#if os(macOS)
216+
view.wrapped.animates = true
217+
#endif
218+
214219
if let image = imageModel.image {
215220
#if os(watchOS)
216221
view.wrapped.setImage(image)
@@ -228,9 +233,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
228233
}
229234

230235
#if os(macOS)
231-
if self.isAnimating != view.wrapped.animates {
232-
view.wrapped.animates = self.isAnimating
233-
}
236+
view.wrapped.animates = self.isAnimating
234237
#else
235238
if self.isAnimating != view.wrapped.isAnimating {
236239
if self.isAnimating {

0 commit comments

Comments
 (0)