@@ -13,6 +13,7 @@ A ScrollView component that handles keyboard appearance and automatically scroll
1313</p >
1414
1515## Supported versions
16+ - ` v0.3.0 ` requires ` RN>=0.48 `
1617- ` v0.2.0 ` requires ` RN>=0.32.0 ` .
1718- ` v0.1.2 ` requires ` RN>=0.27.2 ` but you should use ` 0.2.0 ` in order to make it work with multiple scroll views.
1819- ` v0.0.7 ` requires ` react-native>=0.25.0 ` .
@@ -30,10 +31,10 @@ yarn add react-native-keyboard-aware-scroll-view
3031```
3132
3233## Usage
33- You can use the `` KeyboardAwareScrollView `` or the `` KeyboardAwareListView ` `
34- components. Both accept `` ScrollView `` and `` ListView `` default props and
35- implements a custom `` KeyboardAwareMixin ` ` to handle keyboard appearance.
36- The mixin is also available if you want to use it in any other component.
34+ You can use the ` KeyboardAwareScrollView ` , the ` KeyboardAwareListView ` or the ` KeyboardAwareFlatList `
35+ components. They accept ` ScrollView ` , ` ListView ` and ` FlatList ` default props respectively and
36+ implement a custom high order componente called ` KeyboardAwareHOC ` to handle keyboard appearance.
37+ The high order component is also available if you want to use it in any other component.
3738
3839Import `` react-native-keyboard-aware-scroll-view `` and wrap your content inside
3940it:
@@ -59,17 +60,17 @@ In order to scroll to any `TextInput` field, you can use the built-in method `sc
5960``` js
6061_scrollToInput (reactNode : any ) {
6162 // Add a 'scroll' ref to your ScrollView
62- this .refs . scroll .scrollToFocusedInput (reactNode)
63+ this .scroll . props .scrollToFocusedInput (reactNode)
6364}
6465```
6566
6667``` jsx
67- < KeyboardAwareScrollView ref= ' scroll' >
68+ < KeyboardAwareScrollView innerRef = { ref => { this . scroll = ref}} >
6869 < View>
6970 < TextInput onFocus= {(event : Event ) => {
7071 // `bind` the function if you're using ES6 classes
7172 this ._scrollToInput (ReactNative .findNodeHandle (event .target ))
72- }/ >
73+ } / >
7374 < / View>
7475< / KeyboardAwareScrollView>
7576` ` `
@@ -78,7 +79,7 @@ _scrollToInput (reactNode: any) {
7879There's another built-in function that lets you programatically scroll to any position of the scroll view:
7980
8081` ` ` js
81- this .refs . scroll .scrollToPosition (0 , 0 , true )
82+ this .scroll .props . scrollToPosition (0 , 0 )
8283` ` `
8384
8485## Register to keyboard events
@@ -104,7 +105,7 @@ But if you want to use feature like `extraHeight`, you need to enable Android Su
104105- Set ` windowSoftInputMode` to ` adjustPan` in ` AndroidManifest .xml ` .
105106- Set ` enableOnAndroid` property to ` true ` .
106107
107- Android Suppor is not perfect, here is the support list:
108+ Android Support is not perfect, here is the supported list:
108109
109110| **Prop** | **Android Support** |
110111|----------|-----------------|
@@ -119,10 +120,11 @@ Android Suppor is not perfect, here is the support list:
119120
120121## API
121122### Props
122- All the ` ScrollView` /` ListView` props will be passed.
123+ All the ` ScrollView` /` ListView` / ` FlatList ` props will be passed.
123124
124125| **Prop** | **Type** | **Description** |
125126|----------|----------|-----------------|
127+ | ` innerRef` | ` Function ` | Catch the reference of the component. |
126128| ` viewIsInsideTabBar` | ` boolean` | Adds an extra offset that represents the ` TabBarIOS` height. |
127129| ` resetScrollToCoords` | ` Object : {x: number, y: number}` | Coordinates that will be used to reset the scroll when the keyboard hides. |
128130| ` enableAutoAutomaticScroll` | ` boolean` | When focus in ` TextInput` will scroll the position, default is enabled. |
@@ -132,12 +134,33 @@ All the `ScrollView`/`ListView` props will be passed.
132134| ` keyboardOpeningTime` | ` number` | Sets the delay time before scrolling to new position, default is 250 |
133135| ` enableOnAndroid` | ` boolean` | Enable Android Support |
134136
137+ ### Methods
138+ Use ` innerRef` to get the component reference and use ` this .scrollRef .props ` to access these methods.
139+
135140| **Method** | **Parameter** | **Description** |
136141|------------|---------------|-----------------|
137142| ` getScrollResponder` | ` void ` | Get ` ScrollResponder` |
138143| ` scrollToPosition` | ` x: number, y: number, animated: bool = true ` | Scroll to specific position with or without animation. |
139144| ` scrollToEnd` | ` animated?: bool = true ` | Scroll to end with or without animation. |
140145
146+ ### Using high order component
147+ Enabling any component to be keyboard-aware is very easy. Take a look at the code of ` KeyboardAwareListView` :
148+
149+ ` ` ` js
150+ /* @flow */
151+
152+ import { ListView } from ' react-native'
153+ import listenToKeyboardEvents from ' ./KeyboardAwareHOC'
154+
155+ export default listenToKeyboardEvents (ListView)
156+ ` ` `
157+
141158## License
142159
143160MIT.
161+
162+ ## Author
163+
164+ Álvaro Medina Ballester ` < amedina at apsl .net > `
165+
166+ Built with 💛 by [APSL](https://github.com/apsl).
0 commit comments