Skip to content

Commit

Permalink
Fix Keyboard avoiding View component
Browse files Browse the repository at this point in the history
Reviewed By: ericvicenti

Differential Revision: D5059434

fbshipit-source-id: 3720aa8ee60ed7cc9fd6c3ab7efa38986b806302
  • Loading branch information
Reem Helou authored and facebook-github-bot committed May 22, 2017
1 parent 341970d commit a975c1e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Libraries/Components/Keyboard/KeyboardAvoidingView.js
Expand Up @@ -14,8 +14,8 @@
const Keyboard = require('Keyboard');
const LayoutAnimation = require('LayoutAnimation');
const Platform = require('Platform');
const React = require('React');
const PropTypes = require('prop-types');
const React = require('React');
const TimerMixin = require('react-timer-mixin');
const View = require('View');
const ViewPropTypes = require('ViewPropTypes');
Expand Down Expand Up @@ -93,12 +93,11 @@ const KeyboardAvoidingView = React.createClass({
return 0;
}

const y1 = Math.max(frame.y, keyboardFrame.screenY - this.props.keyboardVerticalOffset);
const y2 = Math.min(frame.y + frame.height, keyboardFrame.screenY + keyboardFrame.height - this.props.keyboardVerticalOffset);
if (frame.y > keyboardFrame.screenY) {
return frame.y + frame.height - keyboardFrame.screenY - this.props.keyboardVerticalOffset;
}
return Math.max(y2 - y1, 0);
const keyboardY = keyboardFrame.screenY - this.props.keyboardVerticalOffset;

// Calculate the displacement needed for the view such that it
// no longer overlaps with the keyboard
return Math.max(frame.y + frame.height - keyboardY, 0);
},

onKeyboardChange(event: ?KeyboardChangeEvent) {
Expand Down

0 comments on commit a975c1e

Please sign in to comment.