import { ViewModel } from "./scroll-to-index-model-initial" ; import { RadListView , ListViewItemSnapMode } from "nativescript-ui-listview" ; import { EventData } from "tns-core-modules/data/observable" ; import { ios as isIOS } from "tns-core-modules/application" ; let viewModelContext ; let scrollFunc = function ( listView ) { listView . scrollToIndex ( 20 , false , ListViewItemSnapMode . Start ) ; } ; let timer ; export function onPageLoaded ( args ) { const page = args . object ; if ( viewModelContext === undefined ) { viewModelContext = new ViewModel ( ) ; } page . bindingContext = viewModelContext ; } export function onDataPopulated ( args ) { const listView = args . object as RadListView ; if ( isIOS ) { if ( timer ) { clearTimeout ( timer ) ; } timer = setTimeout ( scrollFunc , 10 , listView ) ; } else { scrollFunc ( listView ) ; } }