Skip to content

Commit

Permalink
Only scroll to input when hidden by the keyboard (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis authored and alvaromb committed Oct 6, 2016
1 parent ef46a11 commit 153dc08
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/KeyboardAwareMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,18 @@ const KeyboardAwareMixin = {
if (!currentlyFocusedField) {
return
}

UIManager.viewIsDescendantOf(
currentlyFocusedField,
this.getScrollResponder().getInnerViewNode(),
(isAncestor) => {
if (isAncestor) {
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
// Check if the TextInput will be hidden by the keyboard
UIManager.measureInWindow(currentlyFocusedField, (x, y, width, height) => {
if (y + height > frames.endCoordinates.screenY) {
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
}
})
}
}
)
Expand Down

1 comment on commit 153dc08

@msageryd
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
I thought it behaved a little odd before.

Please sign in to comment.