React-native-keyboard-aware-scroll-view: Update scroll position on new line for multi-line textInput

Created on 11 Jul 2017  路  5Comments  路  Source: APSL/react-native-keyboard-aware-scroll-view

Is there a way to scroll vertically center the view when a multi-line textInput has changed height? I don't see anything in the documentation that mentions this.

Most helpful comment

@dmr07 Can't you just call _scrollToInput when the size changes (i.e. onContentSizeChange)?

All 5 comments

@dmr07 Can't you just call _scrollToInput when the size changes (i.e. onContentSizeChange)?

You could also call "scrollToFocusedInput" on textInput edit.

Hey, facing a similar issue. I implemented the suggestions in the Readme but adapted it to scrollToFocusedInput as @Waltari10 suggested. It scrolls very nicely, but it seems to ignore the extraScrollHeight that I had placed on the KeyboardAwareScrollView (maybe this is normal, because I'm telling it to scroll to X place?).

Anyhow, is there any good way to add extra height while using scrollToFocusedInput ?

is there any other solutions here. I'm still looking for.

Ok so I ended up doing this:

  _scrollToInput (reactNode: any) {
       let extraHeight = 156 // twice the height of <Progress/> which avoids keyboard
       this.scroll.scrollToFocusedInput( reactNode, extraHeight)
  }

I added extraHeight to this.scroll.scrollToFocusedInput() and it works, BUT strangely I had to add twice the height I wanted. Adding just 78 (which is the height of my element that floats above the keyboard) didn't get the input in view.

Was this page helpful?
0 / 5 - 0 ratings