Skip to content

Commit b6648fc

Browse files
bugfix ios scroll
copied fix from APSL#426
1 parent 9eee405 commit b6648fc

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

lib/KeyboardAwareHOC.js

+26-11
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,33 @@ function KeyboardAwareHOC(
318318
if (keyboardOpeningTime === undefined) {
319319
keyboardOpeningTime = this.props.keyboardOpeningTime || 0
320320
}
321-
setTimeout(() => {
322-
if (!this.mountedComponent) {
323-
return
324-
}
325-
const responder = this.getScrollResponder()
326-
responder &&
327-
responder.scrollResponderScrollNativeHandleToKeyboard(
321+
if(keyboardOpeningTime > 0) {
322+
setTimeout(() => {
323+
if (!this.mountedComponent) {
324+
return
325+
}
326+
const responder = this.getScrollResponder()
327+
responder &&
328+
responder.scrollResponderScrollNativeHandleToKeyboard(
329+
reactNode,
330+
extraHeight,
331+
true
332+
)
333+
}, keyboardOpeningTime)
334+
} else {
335+
// fix from https://github.com/APSL/react-native-keyboard-aware-scroll-view/pull/426
336+
if (this.mountedComponent) {
337+
UIManager.measureLayout(
328338
reactNode,
329-
extraHeight,
330-
true
331-
)
332-
}, keyboardOpeningTime)
339+
0,
340+
() => {},
341+
(x, y, width, height) => {
342+
findNodeHandle(this._rnkasv_keyboardView), (x, y, width, height) => {
343+
this._rnkasv_keyboardView.scrollToPosition(0, parseInt(y) - height - extraHeight, true);
344+
}
345+
});
346+
}
347+
}
333348
}
334349

335350
scrollIntoView = async (

0 commit comments

Comments
 (0)