transaction: Transaction(animation: .easeInOut) does not appear to work
recurrence opened this issue · comments
Great job on this! I was having a huge problem with AsyncImage redownloading images in lazy stacks that this lib completely eliminates.
The one difference I noticed is that transaction animations don't appear to work. I had a nice ease animation with AsyncImage that does not trigger when I swap it with CachedAsyncImage. Here's my body
var body: some View { GeometryReader { geo in AsyncImage( url: url, transaction: Transaction(animation: .easeInOut) ) { phase in switch phase { case .empty: Rectangle() .fill(Color.gray1) case let .success(image): image.resizable() .scaledToFill() case .failure: Rectangle() .fill(Color.gray1) @unknown default: EmptyView() } } .frame(width: geo.size.width, height: geo.size.height) .clipped() } } }
well, Github's code view leaves much to be desired lol. Hopefully this is more readable
var body: some View {
GeometryReader { geo in
AsyncImage(
url: url,
transaction: Transaction(animation: .easeInOut)
) { phase in
switch phase {
case .empty:
Rectangle()
.fill(Color.gray1)
case let .success(image):
image.resizable()
.scaledToFill()
case .failure:
Rectangle()
.fill(Color.gray1)
@unknown default:
EmptyView()
}
}
.frame(width: geo.size.width, height: geo.size.height)
.clipped()
}
}
}
Thanks! Checkout the new release. Can you tell me if it works?
Updated to 1.2.0 but it didn't seem to change anything?
Update: I dld a clean build and now it's having an effect. However it appears to be the phase transition instead of the transaction transition (EG: my easeinout renders after the image appears rather than easing into the image).
Actually, I take it back. I just went back and compared with AsyncImage and they're matching (I made a bunch of other changes that changed behaviour in the meantime).
So can confirm that this is now supported. Great job!
Thank you! 🚀