Post

Replies

Boosts

Views

Activity

Reply to onScrollPhaseChange doesn't get called when using List
It appears that using the listStyle modifier makes the phase modifier work: List { ForEach(0..<100, id: \.self) { i in Text("Hello, World! \(i)") .id(i) .onAppear { visible[i] = true } .onDisappear { visible[i] = false } } } // without modifier // ❌ // .listStyle(.automatic) // ❌ // .listStyle(.grouped) // ✅ // .listStyle(.inset) // ✅ // .listStyle(.insetGrouped) // ✅ // .listStyle(.plain) // ✅ // .listStyle(.sidebar) // ✅ .onScrollPhaseChange { old, new, _ in print("old: \(old), new: \(new)") if old != .idle, new == .idle { let message = visible.keys.sorted().reduce(into: "") { base, element in base += "i: \(element) (\(visible[element]?.description ?? "null")), " } print(message) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’25