From da27a8c9562fc4a3f6f52760ba46819ee839d478 Mon Sep 17 00:00:00 2001 From: joseph kim Date: Tue, 28 Jun 2016 14:24:18 -0700 Subject: [PATCH] v0.1.2 with ancestor_check - Change method name "viewIsAncestorOf" as "viewIsDescendantOf" according to PR facebook/react-native#7876 --- lib/KeyboardAwareMixin.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/KeyboardAwareMixin.js b/lib/KeyboardAwareMixin.js index 8d740c9..50180eb 100644 --- a/lib/KeyboardAwareMixin.js +++ b/lib/KeyboardAwareMixin.js @@ -1,7 +1,7 @@ /* @flow */ import { PropTypes } from 'react' -import ReactNative, { TextInput, Keyboard } from 'react-native' +import ReactNative, { TextInput, Keyboard, UIManager } from 'react-native' import TimerMixin from 'react-timer-mixin' const _KAM_DEFAULT_TAB_BAR_HEIGHT = 49 @@ -53,7 +53,15 @@ const KeyboardAwareMixin = { return } try { - this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField) + UIManager.viewIsDescendantOf( + currentlyFocusedField, + this.getScrollHandle().getScrollResponder().getInnerViewNode(), + (isAncestor) => { + if (isAncestor) { + this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField) + } + } + ) } catch (e) { }