Add spring to top button
- at the bottom of all articles, before the placeholder
ScrollView {
ScrollViewReader { value in
Button("Jump to #8") {
value.scrollTo(8)
}
ForEach(0..<10) { i in
Text("Example \(i)")
.frame(width: 300, height: 300)
.background(colors[i % colors.count])
.id(i)
}
}
}
value.scrollTo(8, anchor: .top)
Tip: If you call scrollTo() inside withAnimation() the movement will be animated.