Skip to content

The offset animation is not functioning as expected 🧐 #296

Open
@rathodmayur93

Description

@rathodmayur93

Hello,
I want to express my gratitude for developing this library; it has been working exceptionally well for my project. Lately, I've been attempting to apply an offset animation to a WebImage, but unfortunately, the image doesn't animate at all. Interestingly, when I substitute the WebImage with AsyncImage, the animation works perfectly. Does anyone have any insights into why this might be happening?

Code

struct FirstView: View {
    
    @State private var isAnimating: Bool = false
    
    var body: some View {
        ZStack {
            Color.red
            
            VStack {
                
                VStack {
                    WebImage(url: URL(string: "https://picsum.photos/200"))
                        .scaledToFit()
                        .offset(x: isAnimating ? 0 : -1000)
                        .animation(.linear(duration: 2.0), value: isAnimating)
                    
                    AsyncImage(url: URL(string: "https://picsum.photos/200"))
                        .scaledToFit()
                        .offset(x: isAnimating ? 0 : -1000)
                        .animation(.linear(duration: 2.0), value: isAnimating)
                    
                }
                .opacity(isAnimating ? 1 : 0)
                .animation(.linear(duration: 2.0), value: isAnimating)
            }
            .ignoresSafeArea()
            .onAppear {
                isAnimating = true
            }
        }
    }
}

#Preview {
    FirstView()
}

Output

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-01-12.at.15.00.20.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions