0

I want to detect the user's scroll direction on a List to hide some UI elements when they scroll down, and show them when they scroll up.

I'm currently doing the following, but once the user begins scrolling, I don't get any more callbacks here until they completely stop scrolling. I'd like to be able to react in realtime as they scroll up/down without lifting their finger.

List {
  . . .
}.simultaneousGesture(
  DragGesture().onChanged({
    let isScrollDown = 0 < $0.translation.height
    let isScrollUp = 0 > $0.translation.height
    withAnimation {
      if isScrollUp {
        toolbarsCollapsed = true
      } else if isScrollDown {
        toolbarsCollapsed = false
      }
    }
  }))

I found methods that would work if I were using a ScrollView, but I'm using a List. Any ideas?

CompC
  • 381
  • 2
  • 19

0 Answers0