Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scroll down to a specific index of a list contained in a Scrollview ? (Nativescript-vue)

I'm writing a mobile application using nativescript-vue.

I have a list contained in a Scrollview (which is contained in a Tabview). When my app goes to this tab, I want the Scrollview to scroll down to a specific index of the list that is contained.

I tried this :

<ScrollView id="ScrollView" @loaded="onLoaded">
    <ListView for="item in items" class="list-group">
     ...

onLoaded() {         
this.$refs.page.nativeView.getViewById("ScrollView").scrollToVerticalOffset(200, false);
}

This does not work, whatever the value for the offset parameter.

Do I miss something?

Thank you in advance.

like image 701
Bastien Avatar asked Nov 18 '25 10:11

Bastien


1 Answers

It's a mistake to wrap ListView within ScrollView as ListView itself is scrollable. You may use scrollToIndex on RadListView to scroll down / up to specific index.

// Scrolls to 50th index
listView.scrollToIndex(50);

Also make sure your items are populated on UI before you call this method. I think you should use dataPopulatedEvent for that.

like image 128
Manoj Avatar answered Nov 21 '25 00:11

Manoj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!