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

Legacy Swift UI animation modifier required for cross fade transition to function #272

Open
alexfanatics opened this issue Aug 13, 2023 · 2 comments

Comments

@alexfanatics
Copy link

alexfanatics commented Aug 13, 2023

Greetings, great library.

I may be using the APIs incorrectly here, but I can only get the cross fade to function using the legacy animation modifier. Is this usage incorrect? How can I get the cross fade working properly with the modern animation modifier? Thanks!!!

import SwiftUI
import SDWebImageSwiftUI

struct ContentView: View {
    
    @State var url = URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic")
    
    var body: some View {
        VStack {
            Text("old animation modifier")
            WebImage(url: url)
                .resizable()
                .indicator(Indicator { _, _ in EmptyView()})
                .animation(.easeInOut(duration: 3))
                .transition(.fade)
                .scaledToFit()
                .aspectRatio(contentMode: .fit)
                .frame(width: 300, height: 300, alignment: .center)
            Spacer()
            Text("new animation modifier")
            WebImage(url: url)
                .resizable()
                .indicator(Indicator { _, _ in EmptyView()})
                .animation(.easeInOut(duration: 3), value: url)
                .transition(.fade)
                .scaledToFit()
                .aspectRatio(contentMode: .fit)
                .frame(width: 300, height: 300, alignment: .center)
        }
        .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
crossfade_example.mp4
@eccentricyan
Copy link

It doesn't work with lazyvstack, animation goes weird.
I think the linked PR is the correct solution.

@aviwad
Copy link

aviwad commented Aug 29, 2023

It doesn't work with lazyvstack, animation goes weird.

I think the linked PR is the correct solution.

Yeah animation gets erratic. I don't know what other image library to use in my SwiftUI app, because I want to share the cache with my app widget extension as well. Do you have any suggestion?

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

3 participants