I have a list of names that appear vertically thanks to an animation, I would like to have auto-scroll when a new name appears but i don't know how to go on...I saw some questions like this but all of them were a 'jump to a number' solution, not progressively scroll...any suggestions?
UPDATED CODE:
struct ContentView: View {
let correctNames = ["Steve", "Bill", "John", "Elon", "Michael", "Justin", "Marcell", "David", "Gabriel", "Eric", "Jeffrey", "Taylor", "Jennifer", "Christian"]
@State private var animating = false
var body: some View {
VStack {
ScrollView(showsIndicators: false) {
ForEach(0..<correctNames.count, id: \.self) { index in
Text("\(correctNames[index])")
.font(.system(size: 60))
.opacity(animating ? 1 : 0)
.animation(.easeIn(duration: 0.5).delay(Double(index) * 0.2), value: animating)
}
}
}
.onAppear {
animating.toggle()
}
}
}