ScrollViewReader scrollTo ignores withAnimation-Duration

I tried animating the scrollTo() like so, as described in the docs.

Code Block swift
withAnimation {
scrollProxy.scrollTo(index, anchor: .center)
}


the result is the same as if I do

Code Block swift
withAnimation(Animation.easeIn(duration: 20)) {
    scrollProxy.scrollTo(progress.currentIndex, anchor: .center)
}


I tried this using the example from the ScrollViewReader docs.
With the result that up and down scrolling has exactly the same animation.

Code Block
struct ScrollingView: View {
    @Namespace var topID
    @Namespace var bottomID
    var body: some View {
        ScrollViewReader { proxy in
            ScrollView {
                Button("Scroll to Bottom") {
                    withAnimation {
                        proxy.scrollTo(bottomID)
                    }
                }
                .id(topID)
                VStack(spacing: 0) {
                    ForEach(0..<100) { i in
                        color(fraction: Double(i) / 100)
                            .frame(height: 32)
                    }
                }
                Button("Top") {
                    withAnimation(Animation.linear(duration: 20)) {
                        proxy.scrollTo(topID)
                    }
                }
                .id(bottomID)
            }
        }
    }
    func color(fraction: Double) -> Color {
        Color(red: fraction, green: 1 - fraction, blue: 0.5)
    }
}
struct ScrollingView_Previews: PreviewProvider {
    static var previews: some View {
        ScrollingView()
    }
}


i have the same issue, the duration did not work

I have the same issue too.... Please help.

I have same issue as well!

Same issue, couldn’t find a solution on macOS - scrolling has no animation when using scrollTo

Same issue

I also have the same issue, the duration did not work in iOS 15.7.8 - iPhone 7

Same for me on visionOS 1.2.

(deleted)

This seems to work for me:

// If we don't use `DispatchQueue.main.async` here, `withAnimation` has no effect.
DispatchQueue.main.async {
    withAnimation {
        scrollViewProxy.scrollTo(id)
    }
}

Still got the same issue. Xcode 15.3

The issue still exists. 4 years have passed. Why doesn't Apple fix this serious bug?

ScrollViewReader scrollTo ignores withAnimation-Duration
 
 
Q