Skip to content

Commit 99aa515

Browse files
author
alvaromb
committed
0.0.5 Release
closes #6 Solved bug when dismissing keyboard inside closes #1 Added example for scroll 0.0.5
1 parent 0e28087 commit 99aa515

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
A ScrollView component that handles keyboard appearance.
33

44
## Installation
5-
You can install this component through ``npm``:
5+
You need `react-native>=0.12.0` to use this library. Installation can be done through ``npm``:
66

77
```shell
88
npm i react-native-keyboard-aware-scroll-view --save
@@ -32,6 +32,24 @@ import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view
3232
The component accepts the experimental prop ``viewIsInsideTabBar``, which tries
3333
to solve resizing issues when rendering inside a ``TabBar`` component.
3434

35+
## Auto-scroll in `TextInput` fields
36+
In order to perform an auto-scroll whenever a `TextInput` field gets focused, you can use the built-in method `scrollToFocusedInput`. Define the following function for each of your `onFocus` event on your inputs:
37+
38+
```js
39+
_scrollToInput (event, reactNode) {
40+
// Add a 'scroll' ref to your ScrollView
41+
this.refs.scroll.scrollToFocusedInput(event, reactNode)
42+
}
43+
```
44+
45+
```jsx
46+
<KeyboardAwareScrollView ref='scroll'>
47+
<View>
48+
<TextInput ref='myInput' onFocus={this._scrollToInput}/>
49+
</View>
50+
</KeyboardAwareScrollView>
51+
```
52+
3553
## License
3654

3755
MIT.

lib/KeyboardAwareMixin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ const KeyboardAwareMixin = {
2727
},
2828

2929
resetKeyboardSpace: function () {
30+
const keyboardSpace = (this.props.viewIsInsideTabBar) ? _KAM_DEFAULT_TAB_BAR_HEIGHT : 0
3031
this.setState({
31-
keyboardSpace: 0,
32+
keyboardSpace: keyboardSpace,
3233
})
3334
},
3435

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-keyboard-aware-scroll-view",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "A React Native ScrollView component that resizes when the keyboard appears.",
55
"main": "index.js",
66
"scripts": {
@@ -33,10 +33,6 @@
3333
},
3434
"homepage": "https://github.com/APSL/react-native-keyboard-aware-scroll-view#readme",
3535
"dependencies": {
36-
"react-native": ">=0.12.0",
3736
"react-timer-mixin": "^0.13.3"
3837
},
39-
"peerDependencies": {
40-
"react-native": ">=0.12.0"
41-
}
4238
}

0 commit comments

Comments
 (0)