Skip to content

Commit

Permalink
Added extraHeight prop (APSL#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaromb authored Jun 13, 2016
1 parent a428194 commit 07c0672
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/KeyboardAwareMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ import TimerMixin from 'react-timer-mixin'

const _KAM_DEFAULT_TAB_BAR_HEIGHT = 49
const _KAM_KEYBOARD_OPENING_TIME = 250
const _KAM_EXTRA_HEIGHT = 75

const KeyboardAwareMixin = {
mixins: [TimerMixin],
propTypes: {
enableAutoAutomaticScroll: PropTypes.bool
enableAutoAutomaticScroll: PropTypes.bool,
extraHeight: PropTypes.number,
},

getDefaultProps: function () {
return {
enableAutoAutomaticScroll: true,
extraHeight: _KAM_EXTRA_HEIGHT,
}
},

Expand Down Expand Up @@ -87,7 +90,7 @@ const KeyboardAwareMixin = {
/**
* @param extraHeight: takes an extra height in consideration.
*/
scrollToFocusedInput: function (reactNode: Object, extraHeight: number = _KAM_DEFAULT_TAB_BAR_HEIGHT) {
scrollToFocusedInput: function (reactNode: Object, extraHeight: number = this.props.extraHeight) {
const scrollView = this.refs._rnkasv_keyboardView.getScrollResponder()
this.setTimeout(() => {
scrollView.scrollResponderScrollNativeHandleToKeyboard(
Expand All @@ -96,7 +99,7 @@ const KeyboardAwareMixin = {
}, _KAM_KEYBOARD_OPENING_TIME)
},

scrollToFocusedInputWithNodeHandle: function (nodeID: number, extraHeight: number = _KAM_DEFAULT_TAB_BAR_HEIGHT) {
scrollToFocusedInputWithNodeHandle: function (nodeID: number, extraHeight: number = this.props.extraHeight) {
const reactNode = ReactNative.findNodeHandle(nodeID)
this.scrollToFocusedInput(reactNode, extraHeight)
},
Expand Down

0 comments on commit 07c0672

Please sign in to comment.