Post

Replies

Boosts

Views

Activity

[Critical Issue] Content with variable height in a LazyVStack inside a ScrollView causes stuttering / jumping
My goal is to create a chat view in SwiftUI. This requires creating a ScrollView with content of varying heights . After extensive debugging, I've determined that if you have views within a LazyVStack inside of a ScrollView that do not have a fixed height, it will stutter when you scroll to the top of the view. –––– PROJECT: Download this project and try for yourself struct ContentView: View { @State var items: [String] = MockData.randomMessages(count: 100) var body: some View { VStack { Button("Shuffle items") { items = MockData.randomMessages(count: 100) } ScrollView { LazyVStack(spacing: 10) { ForEach(Array(items.enumerated()), id: \.offset) { index, item in Text(item) .background(colors.randomElement()!) } } } } } } My conclusion right now is that LazyVStack only works with child views that have fixed height. This issue alone prevents SwiftUI from being production ready. Has anyone else tackled this?
7
7
9.4k
Oct ’23
[Critical Issue] Content with variable height in a LazyVStack inside a ScrollView causes stuttering / jumping
My goal is to create a chat view in SwiftUI. This requires creating a ScrollView with content of varying heights . After extensive debugging, I've determined that if you have views within a LazyVStack inside of a ScrollView that do not have a fixed height, it will stutter when you scroll to the top of the view. –––– PROJECT: Download this project and try for yourself struct ContentView: View { @State var items: [String] = MockData.randomMessages(count: 100) var body: some View { VStack { Button("Shuffle items") { items = MockData.randomMessages(count: 100) } ScrollView { LazyVStack(spacing: 10) { ForEach(Array(items.enumerated()), id: \.offset) { index, item in Text(item) .background(colors.randomElement()!) } } } } } } My conclusion right now is that LazyVStack only works with child views that have fixed height. This issue alone prevents SwiftUI from being production ready. Has anyone else tackled this?
Replies
7
Boosts
7
Views
9.4k
Activity
Oct ’23