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 theanimate
parameter istrue
- the scrolling will be animated -
scrollToIndex()
- scrolls the list so that the data item at the particular index is brought to visibility. If theanimate
argument istrue
- the scrolling will be animated. The value of thesnapMode
argument determines the position of the target item when it is brought into view. The possible values for this argument are enlisted by theListViewItemSnapMode
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
:
-
scrollStartedEvent
- fired when the list starts scrolling -
scrolledEvent
- fired each time the scroll offset of the list is changed -
scrollDragEndedEvent
- fired each time the user raises their finger from the device's screen as a result of a scrolling gesture -
scrollEndedEvent
- fired when the list stops scrolling
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 theRadListView
component:ListViewLinearLayout
with fixeditemHeight
or to setListViewStaggeredLayout
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.