Skip to content

Commit 1875414

Browse files
antoinegrelardalvaromb
authored andcommitted
fix enableAutoAutomaticScroll prop (#215)
* fix enableAutoAutomaticScroll prop * update enableAutoAutomaticScroll prop name to enableAutomaticScroll * fix prettier formatting
1 parent 3e6f237 commit 1875414

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Android Support is not perfect, here is the supported list:
111111
|----------|-----------------|
112112
| `viewIsInsideTabBar` | Yes |
113113
| `resetScrollToCoords` | Yes |
114-
| `enableAutoAutomaticScroll` | Yes |
114+
| `enableAutomaticScroll` | Yes |
115115
| `extraHeight` | Yes |
116116
| `extraScrollHeight` | Yes |
117117
| `enableResetScrollToCoords` | Yes |
@@ -127,7 +127,7 @@ All the `ScrollView`/`ListView`/`FlatList` props will be passed.
127127
| `innerRef` | `Function` | Catch the reference of the component. |
128128
| `viewIsInsideTabBar` | `boolean` | Adds an extra offset that represents the `TabBarIOS` height. |
129129
| `resetScrollToCoords` | `Object: {x: number, y: number}` | Coordinates that will be used to reset the scroll when the keyboard hides. |
130-
| `enableAutoAutomaticScroll` | `boolean` | When focus in `TextInput` will scroll the position, default is enabled. |
130+
| `enableAutomaticScroll` | `boolean` | When focus in `TextInput` will scroll the position, default is enabled. |
131131
| `extraHeight` | `number` | Adds an extra offset when focusing the `TextInput`s. |
132132
| `extraScrollHeight` | `number` | Adds an extra offset to the keyboard. Useful if you want to stick elements above the keyboard. |
133133
| `enableResetScrollToCoords` | `boolean` | Lets the user enable or disable automatic resetScrollToCoords. |

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ interface KeyboardAwareProps {
4646
* @type {boolean}
4747
* @memberof KeyboardAwareProps
4848
*/
49-
enableAutoAutomaticScroll?: boolean
50-
49+
50+
enableAutomaticScroll?: boolean
5151
/**
5252
* Enables keyboard aware settings for Android
5353
*

lib/KeyboardAwareHOC.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type KeyboardAwareHOCProps = {
2323
y: number
2424
},
2525
enableResetScrollToCoords?: boolean,
26-
enableAutoAutomaticScroll?: boolean,
26+
enableAutomaticScroll?: boolean,
2727
extraHeight?: number,
2828
extraScrollHeight?: number,
2929
keyboardOpeningTime?: number,
@@ -40,7 +40,7 @@ function listenToKeyboardEvents(ScrollableComponent: React$Component) {
4040
return class extends React.Component<
4141
KeyboardAwareHOCProps,
4242
KeyboardAwareHOCState
43-
> implements KeyboardAwareInterface {
43+
> implements KeyboardAwareInterface {
4444
_rnkasv_keyboardView: any
4545
keyboardWillShowEvent: ?Function
4646
keyboardWillHideEvent: ?Function
@@ -58,7 +58,7 @@ function listenToKeyboardEvents(ScrollableComponent: React$Component) {
5858
y: PropTypes.number.isRequired
5959
}),
6060
enableResetScrollToCoords: PropTypes.bool,
61-
enableAutoAutomaticScroll: PropTypes.bool,
61+
enableAutomaticScroll: PropTypes.bool,
6262
extraHeight: PropTypes.number,
6363
extraScrollHeight: PropTypes.number,
6464
keyboardOpeningTime: PropTypes.number,
@@ -69,7 +69,7 @@ function listenToKeyboardEvents(ScrollableComponent: React$Component) {
6969
}
7070

7171
static defaultProps = {
72-
enableAutoAutomaticScroll: true,
72+
enableAutomaticScroll: true,
7373
extraHeight: _KAM_EXTRA_HEIGHT,
7474
extraScrollHeight: 0,
7575
enableResetScrollToCoords: true,
@@ -182,14 +182,13 @@ function listenToKeyboardEvents(ScrollableComponent: React$Component) {
182182

183183
// Keyboard actions
184184
_updateKeyboardSpace = (frames: Object) => {
185-
let keyboardSpace: number =
186-
frames.endCoordinates.height + this.props.extraScrollHeight
187-
if (this.props.viewIsInsideTabBar) {
188-
keyboardSpace -= _KAM_DEFAULT_TAB_BAR_HEIGHT
189-
}
190-
this.setState({ keyboardSpace })
191185
// Automatically scroll to focused TextInput
192-
if (this.props.enableAutoAutomaticScroll) {
186+
if (this.props.enableAutomaticScroll) {
187+
let keyboardSpace: number = frames.endCoordinates.height + this.props.extraScrollHeight
188+
if (this.props.viewIsInsideTabBar) {
189+
keyboardSpace -= _KAM_DEFAULT_TAB_BAR_HEIGHT
190+
}
191+
this.setState({ keyboardSpace })
193192
const currentlyFocusedField = TextInput.State.currentlyFocusedField()
194193
const responder = this.getScrollResponder()
195194
if (!currentlyFocusedField || !responder) {

0 commit comments

Comments
 (0)