Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transaction: Transaction(animation: .easeInOut) does not appear to work #2

Closed
recurrence opened this issue Oct 30, 2021 · 6 comments
Closed

Comments

@recurrence
Copy link

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() } } }

@recurrence
Copy link
Author

recurrence commented Oct 30, 2021

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()
        }
    }
}

@lorenzofiamingo
Copy link
Owner

lorenzofiamingo commented Oct 31, 2021

Thanks! Checkout the new release. Can you tell me if it works?

@recurrence
Copy link
Author

Updated to 1.2.0 but it didn't seem to change anything?

@recurrence
Copy link
Author

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).

@recurrence
Copy link
Author

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!

@lorenzofiamingo
Copy link
Owner

Thank you! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants