From 8d396b1aba6f1d8944eb2e4d13f858b339834e6c Mon Sep 17 00:00:00 2001 From: Thijs Molenaar Date: Thu, 16 Apr 2020 08:38:28 +0200 Subject: [PATCH] Fix "bouncing" when scrolling to input. --- lib/KeyboardAwareHOC.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index 4bf0ed0..710a4a0 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -298,18 +298,17 @@ function KeyboardAwareHOC( if (keyboardOpeningTime === undefined) { keyboardOpeningTime = this.props.keyboardOpeningTime || 0 } - setTimeout(() => { - if (!this.mountedComponent) { - return - } - const responder = this.getScrollResponder() - responder && - responder.scrollResponderScrollNativeHandleToKeyboard( - reactNode, - extraHeight, - true - ) - }, keyboardOpeningTime) + if (this.mountedComponent) { + UIManager.measureLayout( + reactNode, + 0, + () => {}, + (x, y, width, height) => { + findNodeHandle(this._rnkasv_keyboardView), (x, y, width, height) => { + this._rnkasv_keyboardView.scrollToPosition(0, parseInt(y) - height - extraHeight, true); + } + }); + } } scrollIntoView = async (