Skip to content

Commit 8f2054e

Browse files
committed
Change the AnimatedImage AnyView into Group, seems this is more performent
1 parent 9cdd592 commit 8f2054e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,14 @@ extension AnimatedImage {
522522
#if os(macOS) || os(iOS) || os(tvOS)
523523
return self.modifier(EmptyModifier()).aspectRatio(aspectRatio, contentMode: contentMode)
524524
#else
525-
if let aspectRatio = aspectRatio {
526-
return AnyView(self.modifier(EmptyModifier()).aspectRatio(aspectRatio, contentMode: contentMode))
527-
} else {
528-
// on watchOS, there are no workaround like `AnimatedImageViewWrapper` to override `intrinsicContentSize`, so the aspect ratio is undetermined and cause sizing issues
529-
// To workaround, we do not call default implementation for this case, using original solution instead
530-
return AnyView(self)
525+
return Group {
526+
if aspectRatio != nil {
527+
self.modifier(EmptyModifier()).aspectRatio(aspectRatio, contentMode: contentMode)
528+
} else {
529+
// on watchOS, there are no workaround like `AnimatedImageViewWrapper` to override `intrinsicContentSize`, so the aspect ratio is undetermined and cause sizing issues
530+
// To workaround, we do not call default implementation for this case, using original solution instead
531+
self
532+
}
531533
}
532534
#endif
533535
}

0 commit comments

Comments
 (0)