@@ -4,10 +4,11 @@ import React , { Component, PropTypes } from 'react';
4
4
import ReactNative , {
5
5
DeviceEventEmitter ,
6
6
Keyboard ,
7
- NativeModules
7
+ NativeModules ,
8
+ InteractionManager
8
9
} from 'react-native' ;
9
10
10
- var ScrollViewManager = NativeModules . ScrollViewManager ;
11
+ const ScrollViewManager = NativeModules . ScrollViewManager ;
11
12
12
13
export default class KeyboardAwareBase extends Component {
13
14
constructor ( props ) {
@@ -78,9 +79,12 @@ export default class KeyboardAwareBase extends Component {
78
79
if ( this . props . getTextInputRefs ) {
79
80
const textInputRefs = this . props . getTextInputRefs ( ) ;
80
81
textInputRefs . forEach ( ( textInputRef ) => {
81
- if ( textInputRef . isFocused ( ) ) {
82
- this . _keyboardAwareView . getScrollResponder ( ) . scrollResponderScrollNativeHandleToKeyboard (
83
- ReactNative . findNodeHandle ( textInputRef ) , 50 + ( this . props . scrollOffset || 0 ) , true ) ;
82
+ if ( textInputRef && textInputRef . isFocused ( ) ) {
83
+ InteractionManager . runAfterInteractions ( ( ) => {
84
+ this . _keyboardAwareView . getScrollResponder ( ) . scrollResponderScrollNativeHandleToKeyboard (
85
+ ReactNative . findNodeHandle ( textInputRef ) , this . props . scrollToInputAdditionalOffset , true ) ;
86
+ }
87
+ ) ;
84
88
}
85
89
} ) ;
86
90
}
@@ -129,9 +133,11 @@ export default class KeyboardAwareBase extends Component {
129
133
130
134
KeyboardAwareBase . propTypes = {
131
135
startScrolledToBottom : PropTypes . bool ,
132
- scrollToBottomOnKBShow : PropTypes . bool
136
+ scrollToBottomOnKBShow : PropTypes . bool ,
137
+ scrollToInputAdditionalOffset : PropTypes . number
133
138
} ;
134
139
KeyboardAwareBase . defaultProps = {
135
140
startScrolledToBottom : false ,
136
- scrollToBottomOnKBShow : false
141
+ scrollToBottomOnKBShow : false ,
142
+ scrollToInputAdditionalOffset : 75
137
143
} ;
0 commit comments