Skip to content

Commit

Permalink
Merge pull request #30 from SDWebImage/bufix_animated_image_macOS
Browse files Browse the repository at this point in the history
Fix that AnimatedImage on macOS can not restart animation after first stop
  • Loading branch information
dreampiggy authored Oct 26, 2019
2 parents 51f3595 + 01c68e1 commit bd6a9a9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions SDWebImageSwiftUI/Classes/AnimatedImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ public struct AnimatedImage : PlatformViewRepresentable {
}

func updateView(_ view: AnimatedImageViewWrapper, context: PlatformViewRepresentableContext<AnimatedImage>) {
// macOS SDAnimatedImageView.animates should initialize to true in advance before set image
#if os(macOS)
view.wrapped.animates = true
#endif

if let image = imageModel.image {
#if os(watchOS)
view.wrapped.setImage(image)
Expand All @@ -228,9 +233,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
}

#if os(macOS)
if self.isAnimating != view.wrapped.animates {
view.wrapped.animates = self.isAnimating
}
view.wrapped.animates = self.isAnimating
#else
if self.isAnimating != view.wrapped.isAnimating {
if self.isAnimating {
Expand Down

0 comments on commit bd6a9a9

Please sign in to comment.