NativeScript Core

Loading...

RadListView Scrolling

RadListView provides API that allows developers to manually scroll to a particular item or with particular offset. It also exposes several events that can be used to detect changes in the scroll offset triggered by the end user. The following methods related to Scrolling are available:

  • scrollWithAmount() - scrolls the list with a given amount of pixels. If the animate parameter is true - the scrolling will be animated
  • scrollToIndex() - scrolls the list so that the data item at the particular index is brought to visibility. If the animate argument is true - the scrolling will be animated. The value of the snapMode argument determines the position of the target item when it is brought into view. The possible values for this argument are enlisted by the ListViewItemSnapMode enum.
  • getScrollOffset() - returns the current scroll offset of the list

Scroll Events

You can use the following events to detect changes in the scrolling behavior of RadListView:

All scrolling events provide an instance of the ListViewScrollEventData class to their handlers which provides the current scroll offset of the list through its scrollOffset property.

Note that to work scrollToIndex method in iOS properly, make sure you use the correct layout for the RadListView component: ListViewLinearLayout with fixed itemHeight or to set ListViewStaggeredLayout

References

Want to see this scenario in action? Check our SDK examples repo on GitHub. You will find this and many other practical examples with NativeScript UI.