Chris McKnight
Chris McKnight

Reputation: 8590

NativeScript ListView scroll event

How can I detect when a ListView is scrolled?

I tried wrapping the ListView in a ScrollView and using the scroll event on the ScrollView. Doesn't work.

Upvotes: 1

Views: 1823

Answers (1)

JoshSommer
JoshSommer

Reputation: 2618

I've used the PanGesture on a ListView to capture when a user is scrolling up or down.

  const panEvent$ = fromEvent(this.listView, 'pan').pipe(map(
    (event: PanGestureEventData) => event.deltaY
  ));

This will take my listView property and only emit the Y values. you can then determine if they are moving up or down if Y is greater than 0

Upvotes: 2

Related Questions