Skip to content

Commit d812281

Browse files
committed
add props "enableAutoAutomaticScroll", default is enabled
1 parent fe7e315 commit d812281

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/KeyboardAwareMixin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ const KeyboardAwareMixin = {
3434
keyboardSpace: keyboardSpace,
3535
})
3636
// Automatically scroll to focused TextInput
37-
const currentlyFocusedField = TextInput.State.currentlyFocusedField()
38-
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
37+
if (this.props.enableAutoAutomaticScroll) {
38+
const currentlyFocusedField = TextInput.State.currentlyFocusedField()
39+
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
40+
}
3941
},
4042

4143
resetKeyboardSpace: function () {

lib/KeyboardAwareScrollView.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import { ScrollView } from 'react-native'
55
import KeyboardAwareMixin from './KeyboardAwareMixin'
66

77
const KeyboardAwareScrollView = React.createClass({
8+
getDefaultProps: function() {
9+
return {
10+
enableAutoAutomaticScroll: true,
11+
};
12+
},
813
propTypes: {
914
...ScrollView.propTypes,
1015
viewIsInsideTabBar: PropTypes.bool,
16+
enableAutoAutomaticScroll: PropTypes.bool,
1117
resetScrollToCoords: PropTypes.shape({
1218
x: PropTypes.number,
1319
y: PropTypes.number,

0 commit comments

Comments
 (0)