@@ -275,9 +275,8 @@ public struct AnimatedImage : PlatformViewRepresentable {
275275 self . imageModel. placeholderView? . isHidden = false
276276 self . imageHandler. failureBlock ? ( error ?? NSError ( ) )
277277 }
278- // Finished loading
279- configureView ( view, context: context)
280- layoutView ( view, context: context)
278+ // Finished loading, async
279+ finishUpdateView ( view, context: context, image: image)
281280 }
282281 }
283282
@@ -310,6 +309,8 @@ public struct AnimatedImage : PlatformViewRepresentable {
310309 #endif
311310 context. coordinator. imageLoading. imageName = name
312311 view. wrapped. image = image
312+ // Finished loading, sync
313+ finishUpdateView ( view, context: context, image: image)
313314 }
314315
315316 private func updateViewForData( _ data: Data ? , view: AnimatedImageViewWrapper , context: Context ) {
@@ -323,6 +324,8 @@ public struct AnimatedImage : PlatformViewRepresentable {
323324 }
324325 context. coordinator. imageLoading. imageData = data
325326 view. wrapped. image = image
327+ // Finished loading, sync
328+ finishUpdateView ( view, context: context, image: image)
326329 }
327330
328331 private func updateViewForURL( _ url: URL ? , view: AnimatedImageViewWrapper , context: Context ) {
@@ -347,6 +350,8 @@ public struct AnimatedImage : PlatformViewRepresentable {
347350 setupIndicator ( view, context: context)
348351 loadImage ( view, context: context)
349352 }
353+ // Finished loading, sync
354+ finishUpdateView ( view, context: context, image: view. wrapped. image)
350355 }
351356
352357 func updateView( _ view: AnimatedImageViewWrapper , context: Context ) {
@@ -364,9 +369,6 @@ public struct AnimatedImage : PlatformViewRepresentable {
364369 break // impossible
365370 }
366371
367- // Finished loading
368- configureView ( view, context: context)
369- layoutView ( view, context: context)
370372 if let viewUpdateBlock = imageHandler. viewUpdateBlock {
371373 viewUpdateBlock ( view. wrapped, context)
372374 }
@@ -384,6 +386,17 @@ public struct AnimatedImage : PlatformViewRepresentable {
384386 }
385387 }
386388
389+ func finishUpdateView( _ view: AnimatedImageViewWrapper , context: Context , image: PlatformImage ? ) {
390+ // Finished loading
391+ if let imageSize = image? . size {
392+ view. imageSize = imageSize
393+ } else {
394+ view. imageSize = nil
395+ }
396+ configureView ( view, context: context)
397+ layoutView ( view, context: context)
398+ }
399+
387400 func layoutView( _ view: AnimatedImageViewWrapper , context: Context ) {
388401 // AspectRatio && ContentMode
389402 #if os(macOS)
0 commit comments