From 0870c8ddfd4be223654a2264b6e940a0126563f0 Mon Sep 17 00:00:00 2001 From: alvaromb Date: Wed, 1 Jun 2016 16:26:27 +0200 Subject: [PATCH] A version with the RN ancestor stuff --- lib/KeyboardAwareListView.js | 4 ++++ lib/KeyboardAwareMixin.js | 17 +++++++++++++---- lib/KeyboardAwareScrollView.js | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/KeyboardAwareListView.js b/lib/KeyboardAwareListView.js index 0177873..dfeb3ad 100644 --- a/lib/KeyboardAwareListView.js +++ b/lib/KeyboardAwareListView.js @@ -20,6 +20,10 @@ const KeyboardAwareListView = React.createClass({ this.setResetScrollToCoords(this.props.resetScrollToCoords) }, + getScrollHandle: function () { + return this.refs._rnkasv_keyboardView + }, + render: function () { return ( { + if (isAncestor) { + this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField) + } + } + ) }, resetKeyboardSpace: function () { @@ -68,7 +77,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 = _KAM_EXTRA_HEIGHT) { const scrollView = this.refs._rnkasv_keyboardView.getScrollResponder() this.setTimeout(() => { scrollView.scrollResponderScrollNativeHandleToKeyboard( @@ -77,7 +86,7 @@ const KeyboardAwareMixin = { }, _KAM_KEYBOARD_OPENING_TIME) }, - scrollToFocusedInputWithNodeHandle: function (nodeID: number, extraHeight: number = _KAM_DEFAULT_TAB_BAR_HEIGHT) { + scrollToFocusedInputWithNodeHandle: function (nodeID: number, extraHeight: number = _KAM_EXTRA_HEIGHT) { const reactNode = ReactNative.findNodeHandle(nodeID) this.scrollToFocusedInput(reactNode, extraHeight) }, diff --git a/lib/KeyboardAwareScrollView.js b/lib/KeyboardAwareScrollView.js index 41e6ed7..eb433f4 100644 --- a/lib/KeyboardAwareScrollView.js +++ b/lib/KeyboardAwareScrollView.js @@ -20,6 +20,10 @@ const KeyboardAwareScrollView = React.createClass({ this.setResetScrollToCoords(this.props.resetScrollToCoords) }, + getScrollHandle: function () { + return this.refs._rnkasv_keyboardView + }, + render: function () { return (