Created
October 22, 2020 12:28
-
-
Save danhalliday/603024eb311b7a6ac90aabbbd8aa3cf8 to your computer and use it in GitHub Desktop.
Test case for LazyVStack scrolling behaviour with a large number of items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
let count = 1_000_000 | |
var body: some View { | |
ScrollViewReader { reader in | |
VStack { | |
Button(action: { reader.scrollTo(100, anchor: .center) }) { | |
Text("Scroll to 100") // Works | |
} | |
Button(action: { reader.scrollTo(count, anchor: .center) }) { | |
Text("Scroll to \(count)") // Hangs above 10,000 rows | |
} | |
ScrollView { | |
LazyVStack { | |
ForEach(1...count, id: \.self) { | |
Text("Row \($0)").id($0) | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment