I am trying to implement a ScrollView that scrolls visible automatically to the end of an array. There are some examples in the AppStore where content starts scrolling automatically and you can see it slowly. With this code below it will automatically scroll to the last item without seeing it. How can I add a duration or animation to it that I can see it scrolling?
ScrollView(.horizontal, showsIndicators: false) {
ScrollViewReader {
scrollView in
LazyHStack {
ForEach(self.drinkNames, id: \.self) {
drink in
ShowContent(drink: drink)
.padding(.leading)
}
}
.onAppear {
scrollView.scrollTo(drinkNames[drinkNames.endIndex - 1])
}
}
}