React Native - Scroll Listview at particular position - Programatically -


in ios objective-c can make uitableview scroll particular row index using scrolltorowatindexpath method in react-native did not find such way scroll listview @ particular row index.

following scenario,

  1. there listview such expandable rows while tapping expands , expandable row contains textinput component.
  2. while inputting text in textinput, keyboard shown , ideally @ moment listview should scrolled (once keyboard down listview should scrolled down previous position).

this can achieved native-ios stuck in react-native.

enter image description here


i tried following way did not achieve well

there method called scrollto(x:0,y:10,animated:true) in listview component (actually method of scrollview) can scrolled up/down based on y coordinate of parent view.

i receive keyboard's & down events in code , based on can somehow manage scrollto method (by calculating y coordinate) when keyboard gets (as mentioned in @alexey's answer) have no idea how calculate y coordinate when keyboard gets down? (at moment ideally, listview should scroll down previous position).

any or hint appreciated!

what row height * item index? let's want scroll 20th element in listview. each row has height: 50. calculate offset @ 20th element using formula mentioned above: 50 * 20 = 1000. use scrollto(0, 1000) , you'll scroll desired element.

to able scroll back, need store offset before apply scrollto function:

var scrollproperties = this.refs.listview.scrollproperties; var scrolloffset = scrollproperties.contentlength - scrollproperties.visiblelength; 

after hook on keyboard's event (keyboardwillhide deviceeventemitter), can scrollto previous offset.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -